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

Function apply_agent_help

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

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

Calls

no outgoing calls