View Source Clik (Clik v0.2.2)
Link to this section Summary
Functions
CLI execution entry point.
Link to this section Types
@type argv() :: [] | [String.t()]
Raw args from CLI
@type error() :: {:missing_option, atom()} | {:unknown_command, atom()} | {:unknown_options, [String.t()]} | {:error, :missing_command} | {:error, atom()}
Error during arg parsing or command dispatch
@type result() :: :ok | error()
Execution result
Link to this section Functions
@spec run(Clik.Configuration.t(), argv(), Clik.CommandEnvironment.t()) :: result()
CLI execution entry point.
Parses CLI args based on the configuration and calls the correct command.
run/2
should be called from the main function.
example
Example
defmodule MyCLIApp do
alias Clik.Configuration
def main(args) do
config =
Configuration.add_command!(%Configuration{}, Command.new!(:default, MyCLIApp.DefaultCommand))
case Clik.run(config, args) do
:ok ->
:erlang.halt(0)
{:error, reason} ->
:erlang.halt(1)
end
end