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

Function apply_agent_help

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

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

Calls

no outgoing calls