View Source CLIX.Spec (clix v0.1.0)
The spec builder.
A spec is the basis for parsing, feedback generation, etc.
Summary
Types
The name of a positional argument.
The parsing spec of positional argument.
The name of a command.
The parsing spec of a command.
Custom type.
The number of arguments that should be consumed.
The name of an optional argument.
The parsing spec of optional argument.
The spec.
The type which the argument will be parsed as.
Types
@type action() :: :store | :count | :append
@type arg_name() :: atom()
The name of a positional argument.
@type arg_spec() :: %{ optional(:type) => type(), optional(:nargs) => nargs(), optional(:default) => any(), optional(:value_name) => value_name(), optional(:help) => String.t() | nil }
The parsing spec of positional argument.
@type cmd_name() :: atom()
The name of a command.
The top-level cmd_name is the program name. If you name your CLI app as example,
then you should set the top-level cmd_name as :example
.
@type cmd_spec() :: %{ help: String.t() | nil, summary: String.t() | nil, description: String.t() | nil, cmds: [{cmd_name(), cmd_spec()}], args: [{arg_name(), arg_spec()}], opts: [{opt_name(), opt_spec()}], epilogue: String.t() | nil }
The parsing spec of a command.
If the :help
option isn't set, it will default to the value of :summary
option.
@type custom_type() :: {:custom, (raw_value :: String.t() -> {:ok, value :: term()} | {:error, reason :: String.t()})}
Custom type.
@type nargs() :: nil | :"?" | :* | :+
The number of arguments that should be consumed.
nil
- consume one argument.:"?"
- consume zero or one argument.:*
- consume zero or more arguments.:+
- consume one or more arguments.
@type opt_name() :: atom()
The name of an optional argument.
@type opt_spec() :: %{ optional(:short) => String.t() | nil, optional(:long) => String.t() | nil, optional(:type) => type(), optional(:action) => action(), optional(:default) => any(), optional(:value_name) => value_name(), optional(:help) => String.t() | nil }
The parsing spec of optional argument.
The spec.
@type type() :: :string | :boolean | :integer | :float | custom_type()
The type which the argument will be parsed as.
@type value_name() :: String.t() | nil