diff options
Diffstat (limited to 'src/cli')
| -rw-r--r-- | src/cli/spec.rs | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/cli/spec.rs b/src/cli/spec.rs index ba454bfc..b2b6cb03 100644 --- a/src/cli/spec.rs +++ b/src/cli/spec.rs @@ -43,18 +43,23 @@ pub(super) fn command() -> Command { .subcommand(session_command()) .subcommand(integration_command()) .subcommand(plugin_command()); - configure_help(command, true) + configure_help(command, 0) } -fn configure_help(command: Command, root: bool) -> Command { - let command = if root { +fn configure_help(command: Command, depth: usize) -> Command { + let command = if depth == 0 { command } else { command.disable_help_flag(false) }; + let command = if depth == 1 && command.has_subcommands() { + command.after_help(super::AGENT_HELP_FOOTER) + } else { + command + }; command .disable_help_subcommand(true) - .mut_subcommands(|subcommand| configure_help(subcommand, false)) + .mut_subcommands(|subcommand| configure_help(subcommand, depth + 1)) } pub(super) fn print_requested_help(args: &[String]) -> std::io::Result<bool> { @@ -1307,6 +1312,23 @@ mod tests { } #[test] + fn agent_resources_appear_on_command_groups_but_not_leaf_commands() { + for group in ["agent", "pane", "workspace", "terminal"] { + let help = long_help(&[group]); + assert!( + help.contains(super::super::AGENT_HELP_FOOTER), + "herdr {group} is missing agent resources: {help}" + ); + } + + let leaf = long_help(&["agent", "wait"]); + assert!( + !leaf.contains(super::super::AGENT_HELP_FOOTER), + "leaf help should stay focused: {leaf}" + ); + } + + #[test] fn next_step_hints_render_without_replacing_existing_after_help() { let agent_start = long_help(&["agent", "start"]); assert!( |
