View Source Clik.Configuration (Clik v0.2.2)

Collects commands and global options.

Link to this section Summary

Types

t()

Global CLI app configuration

Functions

Add a command to the application configuration.

Add a command to the application configuration.

Add a global option to the application configuration.

Add a global option to the application configuration.

Does the configuration contain a named command?

Fetch complete set of options for a given named command.

Fetch complete set of options for a given named command.

Link to this section Types

@type t() :: %Clik.Configuration{
  commands: %{required(atom()) => Clik.Command.t()},
  global_options: %{required(atom()) => Clik.Option.t()},
  has_default: boolean(),
  script_help: term()
}

Global CLI app configuration

Link to this section Functions

Link to this function

add_command(config, command)

View Source (since 0.1.0)
@spec add_command(t(), Clik.Command.t()) ::
  {:ok, t()}
  | {:error, :duplicate_command}
  | {:error, :duplicate_option, Clik.Option.t()}

Add a command to the application configuration.

Returns {:error, :duplicate_command} or {:error, :duplication_option, option} on error.

Link to this function

add_command!(config, command)

View Source (since 0.1.0)
@spec add_command!(t(), Clik.Command.t()) :: t() | no_return()

Add a command to the application configuration.

Raises Clik.DuplicateCommandNameError or Clik.DuplicateOptionError on error.

Link to this function

add_global_option(config, option)

View Source (since 0.1.0)
@spec add_global_option(t(), Clik.Option.t()) :: {:ok, t()} | {:error, :duplicate}

Add a global option to the application configuration.

Returns {:error, :duplicate} on error.

Link to this function

add_global_option!(config, option)

View Source (since 0.1.0)
@spec add_global_option!(t(), Clik.Option.t()) :: t() | no_return()

Add a global option to the application configuration.

Raises Clik.DuplicateOptionError on error.

Link to this function

command(config, name)

View Source (since 0.1.0)
@spec command(t(), atom()) :: {:ok, Clik.Command.t()} | {:error, :unknown_command}

Look up Clik.Command by name.

Returns {:error, :unknown_command} if name is not found.

Link to this function

command!(config, name)

View Source (since 0.1.0)
@spec command!(t(), atom()) :: Clik.Command.t() | no_return()

Look up Clik.Command by name.

Raises Clik.UnknownCommandNameError if name is not found.

Link to this function

has_command?(config, name)

View Source (since 0.1.0)
@spec has_command?(t(), atom()) :: boolean()

Does the configuration contain a named command?

Link to this function

new(script_help \\ nil)

View Source (since 0.1.0)

Creates a new Clik.Configuration instance

Link to this function

options(config, command_name \\ nil)

View Source (since 0.1.0)
@spec options(t(), atom()) ::
  {:ok, %{required(atom()) => Clik.Option.t()}} | {:error, :unknown_command}

Fetch complete set of options for a given named command.

The complete set of options includes options specific to the command and global options.

Returns {:error, :unknown_command} when command name is not found.

Link to this function

options!(config, command_name \\ nil)

View Source (since 0.1.0)
@spec options!(t(), atom()) :: %{required(atom()) => Clik.Option.t()} | no_return()

Fetch complete set of options for a given named command.

See Clik.Configuration.options/2 for more information.

Raises Clik.UnknownCommandNameError when command not found.