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

Function apply_agent_help

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

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

Calls 1

collectMethod · 0.45