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

Function apply_agent_help

atomic-cli/src/main.rs:155–170  ·  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

153/// not fall back to its expanded, multi-paragraph layout for one command while
154/// staying compact for another — the whole tree renders the same terse way.
155fn apply_agent_help(cmd: clap::Command) -> clap::Command {
156 let subcommand_names: Vec<String> = cmd
157 .get_subcommands()
158 .map(|c| c.get_name().to_string())
159 .collect();
160
161 let mut cmd = cmd
162 .help_template(AGENT_HELP_TEMPLATE)
163 .long_about(None::<&str>)
164 .mut_args(|arg| arg.long_help(None::<&str>));
165
166 for name in subcommand_names {
167 cmd = cmd.mut_subcommand(name, apply_agent_help);
168 }
169 cmd
170}
171
172// CLI Argument Definitions
173

Calls 1

collectMethod · 0.45