Skip to main content

build_module_command

Function build_module_command 

Source
pub fn build_module_command(
    module_def: &ModuleDescriptor,
) -> Result<Command, CliError>
Expand description

Build a clap Command for a single module definition.

The resulting subcommand has:

  • its name set to module_def.name
  • its about derived from the module descriptor (empty if unavailable)
  • the built-in dispatch flags (--input, --yes/-y, --large-input, --format, --sandbox, --dry-run, --trace, --stream, --strategy, --fields, --approval-timeout, --approval-token)
  • schema-derived flags from schema_to_clap_args

The executor is NOT embedded in the clap::Command — clap has no user-data attachment. Dispatch is handled separately by dispatch_module which receives the executor as a parameter.

§Errors

Returns CliError::ReservedModuleId when module_def.name is one of the reserved built-in command names.

Design note (audit D9): This is a convenience wrapper over build_module_command_with_limit that supplies the default HELP_TEXT_MAX_LEN. Audit D9 flagged the pair as bloat, but the wrapper is consumed by main.rs:624 and 8+ unit tests as the ergonomic default form. Migrating those callers to construct an explicit limit at every site would add ~15 lines of churn for a 1-line save. Retained intentionally.