View Source Escript.Example (nexus_cli v0.5.0)

This is an example on how to use Nexus with an escript application.

After defined :escript entry into your project/0 function on mix.exs and set the main_module option, you can safely define your commands as usual with defcommand/2, CLI config and handlers.

Then you need to call parse/0 macro, which will inject both parse/1 and run/1 function, which the latter you can delegate from the main/1 escript funciton, as can seen below.

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.Escript.Example)

Functions

Link to this function

display_help(path \\ [])

View Source

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> Escript.Example.display_help()
# prints help for the CLI itself showing all available commands and flags
:ok

iex> Escript.Example.display_help([:root])
# prints help for the `root` cmd showing all available subcommands and flags
:ok

iex> Escript.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.Escript.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

See Escript.Example.execute/1.