MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / apply_agent_help

Function apply_agent_help

atomic-cli/src/main.rs:134–149  ·  view source on GitHub ↗

Recursively apply the agent-native help layout to a command and every one of its (transitive) subcommands. clap does not propagate `help_template` to subcommands, so we walk the tree once at startup and set it everywhere. This makes the whole CLI render help the same agent-native way for free — any command added later is covered without touching its definition. In the same pass we drop each comma

(cmd: clap::Command)

Source from the content-addressed store, hash-verified

132/// not fall back to its expanded, multi-paragraph layout for one command while
133/// staying compact for another — the whole tree renders the same terse way.
134fn apply_agent_help(cmd: clap::Command) -> clap::Command {
135 let subcommand_names: Vec<String> = cmd
136 .get_subcommands()
137 .map(|c| c.get_name().to_string())
138 .collect();
139
140 let mut cmd = cmd
141 .help_template(AGENT_HELP_TEMPLATE)
142 .long_about(None::<&str>)
143 .mut_args(|arg| arg.long_help(None::<&str>));
144
145 for name in subcommand_names {
146 cmd = cmd.mut_subcommand(name, apply_agent_help);
147 }
148 cmd
149}
150
151// CLI Argument Definitions
152

Calls

no outgoing calls