View Source mix example (nexus_cli v0.5.0)
This is a Mix Task example using Nexus.
Basically, you can use
both Mix.Task
and Nexus.CLI
modules, define your commands as usual with defcommand/2
and implement others callbacks.
In a Mix.Task
module, the run/1
function will supply
the behaviour, so you don't need to define it yourself.
If you need to do other computations inside Mix.Task.run/1
,
then simply define run/1
by yourself and call __MODULE__.run/1
when you need it, passing the raw args to it.
Summary
Functions
Prints CLI documentation based into the CLI spec defined given a command path
Given the system argv
, tries to parse the input
and dispatches the parsed command to the handler
module (aka Elixir.Mix.Tasks.Example
)
Functions
Prints CLI documentation based into the CLI spec defined given a command path
For more information, check Nexus.CLI.Help
It receives an optional command path, for displaying subcommands help, for example
Examples
iex> Mix.Tasks.Example.display_help()
# prints help for the CLI itself showing all available commands and flags
:ok
iex> Mix.Tasks.Example.display_help([:root])
# prints help for the `root` cmd showing all available subcommands and flags
:ok
iex> Mix.Tasks.Example.display_help([:root, :nested])
# prints help for the `root -> :nested` subcmd showing all available subcommands and flags
:ok
Given the system argv
, tries to parse the input
and dispatches the parsed command to the handler
module (aka Elixir.Mix.Tasks.Example
)
If it fails it will display the CLI help. This
convenience function can be used as delegated
of an Escript
or Mix.Task
module
For more information chekc Nexus.CLI.__run_cli__/2