Macro molt_forked::gen_subcommand
source · macro_rules! gen_subcommand { ($ctx_type:ty, $subc:expr, [ $( ($cmd_name:tt, $cmd_space:tt, $cmd_func:expr, $cmd_help:expr$(,)?) ),* $(,)?] $(,)?) => { ... }; }
Expand description
A Molt command that has subcommands is called an ensemble command. In Rust code,
the ensemble is defined as an array of Subcommand structs, each one mapping from
a subcommand name to the implementing CommandFunc. For more information,
see the discussion of command definition in The Molt Book and the interp module.
The tuple fields are the subcommand’s name and implementing CommandFunc.
Calls a subcommand of the current command, looking up its name in an array of
Subcommand tuples.
The subcommand, if found, is called with the same context_ids and argv as its
parent ensemble. subc is the index of the subcommand’s name in the argv array;
in most cases it will be 1, but it is possible to define subcommands with
subcommands of their own. The subcommands argument is a borrow of an array of
Subcommand records, each defining a subcommand’s name and CommandFunc.
If the subcommand name is found in the array, the matching CommandFunc is called.
otherwise, the error message gives the ensemble syntax. If an invalid subcommand
name was provided, the error message includes the valid options.
See the implementation of the array command in commands.rs and the
module level documentation for examples.