From 1af1a5b86f642ae7b053037bc472913cfbc1e206 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 14 Aug 2026 04:22:48 +0300 Subject: feat(cli): guide agents to Herdr resources --- src/cli/spec.rs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/cli') 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 { @@ -1306,6 +1311,23 @@ mod tests { String::from_utf8(output).unwrap() } + #[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"]); -- cgit v1.2.3