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.

defCommand.abouts#
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.

defCommand.about_of#
pub def Command.about_of (name : String) : String
defCommand.spec#
pub def Command.spec (version : String) : Cli.CommandSpec

The public spec: the derived one plus the program name, about and version.

defCommand.normalize_args#
pub def Command.normalize_args (args : List String) : List String

Parse 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.

defCommand.parse_and_run#
pub def Command.parse_and_run (version : String) (args : List String) (handler : Command -> IO I64) : IO I64
defCommand.help_text#
pub def Command.help_text (version : String) : String

The generated help text for the help subcommand.

defCommand.from_args#
pub def Command.from_args (args : List String) : Command

The 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.

defCommand.debug_of#
pub def Command.debug_of (cmd : Command) : Bool

The effective debug-info setting for the two verbs that build a binary: on by default, --release opts out, an explicit --debug opts back in.