View Source Clik.Command behaviour (Clik v0.2.1)

Link to this section Summary

Types

List of command options

t()

An executable command

Callbacks

Returns short help blurb

Returns list of command-specific options

Executes the command

Functions

Fetch command implementation's help blurb.

Fetch list of command-specific options.

Executes a command.

Link to this section Types

@type option_map() :: %{} | %{required(atom()) => Clik.Option.t()}

List of command options

@type result() :: :ok | {:error, atom()}
@type t() :: %Clik.Command{cb_mod: module(), default?: boolean(), name: atom()}

An executable command

Link to this section Callbacks

@callback help_text() :: String.t() | nil

Returns short help blurb

@callback options() :: option_map()

Returns list of command-specific options

@callback run(Clik.CommandEnvironment.t()) :: result()

Executes the command

Link to this section Functions

Link to this function

help_text(cmd)

View Source (since 0.1.0)
@spec help_text(t()) :: String.t()

Fetch command implementation's help blurb.

Link to this function

new(name, callback_module, default \\ false)

View Source (since 0.1.0)
@spec new(atom(), module(), boolean()) :: {:ok, t()} | {:error, :badarg}

Creates a new Clik.Command instance.

Returns {:error, :badarg} if:

Link to this function

new!(name, callback_module, default \\ false)

View Source (since 0.1.0)
@spec new!(atom(), module(), boolean()) :: t() | no_return()

Creates a new Clik.Command instance.

Raises ArgumentError if:

Link to this function

options(cmd)

View Source (since 0.1.0)
@spec options(t()) :: option_map()

Fetch list of command-specific options.

Link to this function

run(cmd, env)

View Source (since 0.1.0)
@spec run(t(), Clik.CommandEnvironment.t()) :: result()

Executes a command.