cli::cli_spec
cli/src/cli_spec.mo
The spec main parses against, and the thin facade the parser and tests
use.
It lives here, not in cli.mo, for the reason motes/monadup/src/ dispatch.mo documents: the derive's capture re-checks every def in the
expanded module before the generated decls exist, so a same-module consumer
fails with "unbound variable spec_command". A module loaded after
cli.mo has expanded is the supported shape.
pub def Command.abouts : List (Pair String String)One line per subcommand, rendered by the generated --help.
The derive has no constructor-level attribute (CtorInfo carries only a
name and its fields), so the descriptions are attached to the derived spec
here rather than beside each constructor.
pub def Command.about_of (name : String) : Stringpub def Command.spec (version : String) : Cli.CommandSpecThe public spec: the derived one plus the program name, about and version.
pub def Command.normalize_args (args : List String) : List StringParse args, decode and run handler. Help/version print and exit 0; a
usage error prints error: ... plus usage and exits 2.
monad s is the short spelling of monad script. The derive has no
alias attribute, so the first argument is rewritten before parsing.
pub def Command.parse_and_run (version : String) (args : List String) (handler : Command -> IO I64) : IO I64pub def Command.help_text (version : String) : StringThe generated help text for the help subcommand.
pub def Command.from_args (args : List String) : CommandThe argv parser used by the smoke tests. It keeps the old Command
return shape (anything the parser rejects is Command.help); the real
entry point uses Command.parse_and_run, which preserves the error and
the exit code.
pub def Command.debug_of (cmd : Command) : BoolThe effective debug-info setting for the two verbs that build a binary:
on by default, --release opts out, an explicit --debug opts back in.