Cheer.Command behaviour (Cheer v0.1.3)

Copy Markdown View Source

Behaviour and macros for defining CLI commands.

A command is a module that declares its name, description, arguments, options, and subcommands. Commands compose into trees of arbitrary depth.

Example

defmodule MyApp.CLI.Deploy do
  use Cheer.Command

  command "deploy" do
    about "Deploy to an environment"

    subcommand MyApp.CLI.Deploy.Staging
    subcommand MyApp.CLI.Deploy.Production
  end
end

Leaf commands (those with no subcommands) must implement run/2. Branch commands (those with subcommands) route to children automatically.

Summary

Callbacks

Called when this command is matched and has no further subcommands to dispatch to. Receives parsed arguments/options and raw remaining argv.

Callbacks

run(args, raw)

(optional)
@callback run(args :: map(), raw :: [String.t()]) :: term()

Called when this command is matched and has no further subcommands to dispatch to. Receives parsed arguments/options and raw remaining argv.