CliDeps.Tool (CliDeps v0.1.1)

Copy Markdown View Source

A declared external command-line dependency.

Tools are declared through CliDeps's tool/2 macro rather than built directly; this struct is what that produces and what CliDeps.Check acts on.

Summary

Types

Per-operating-system install instructions. The :default key is used when the running system has no specific entry.

The version-matching pattern, stored as regex source rather than a compiled Regex.

t()

Functions

The install hint for the current operating system, or nil if none applies.

Builds a tool from its declared options.

A coarse key for the running operating system.

Types

install()

@type install() :: keyword(String.t())

Per-operating-system install instructions. The :default key is used when the running system has no specific entry.

pattern()

@type pattern() :: String.t() | nil

The version-matching pattern, stored as regex source rather than a compiled Regex.

Tool declarations are macros, so a tool ends up in a module attribute at compile time — and a compiled Regex carries a reference, which cannot be escaped into one. Keeping the source string means declarations stay compile-time data; CliDeps.Check compiles it when it runs.

t()

@type t() :: %CliDeps.Tool{
  allow_nonzero: boolean(),
  executable: String.t(),
  install: install(),
  label: String.t(),
  name: atom(),
  requirement: Version.requirement() | nil,
  timeout: pos_integer() | :infinity,
  version_args: [String.t()],
  version_pattern: pattern()
}

Functions

install_hint(tool)

@spec install_hint(t()) :: String.t() | nil

The install hint for the current operating system, or nil if none applies.

Falls back to the :default entry when the running system has no specific instruction.

new(name, opts \\ [])

@spec new(
  atom(),
  keyword()
) :: t()

Builds a tool from its declared options.

Raises ArgumentError for options that cannot work, rather than deferring the failure to the first check.

os_key()

@spec os_key() :: :macos | :linux | :windows

A coarse key for the running operating system.

Distinguishing Debian from Fedora would need to read /etc/os-release, and a wrong guess prints a command that does not exist — so Linux stays a single bucket and packages that care can supply :default.