From 2a2e20541490d01b213816bcaba710b9571dd377 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 9 Apr 2026 14:06:26 +0900 Subject: [PATCH] fix(cli): intercept --help for prompt/login/logout/version subcommands before API dispatch 'claw prompt --help' was triggering an API call instead of showing help because --help was parsed as part of the prompt args. Now '--help' after known pass-through subcommands (prompt, login, logout, version, state, init, export, commit, pr, issue) sets wants_help=true and shows the top-level help page. Subcommands that consume their own args (agents, mcp, plugins, skills) and local help-topic subcommands (status, sandbox, doctor) are excluded from this interception so their existing --help handling is preserved. 156 CLI tests pass, fmt clean. --- rust/crates/rusty-claude-cli/src/main.rs | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index faf81dd..e34bf99 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -382,7 +382,7 @@ fn parse_args(args: &[String]) -> Result { let mut compact = false; let mut base_commit: Option = None; let mut reasoning_effort: Option = None; - let mut rest = Vec::new(); + let mut rest: Vec = Vec::new(); let mut index = 0; while index < args.len() { @@ -391,6 +391,31 @@ fn parse_args(args: &[String]) -> Result { wants_help = true; index += 1; } + "--help" | "-h" + if !rest.is_empty() + && matches!( + rest[0].as_str(), + "prompt" + | "login" + | "logout" + | "version" + | "state" + | "init" + | "export" + | "commit" + | "pr" + | "issue" + ) => + { + // `--help` following a subcommand that would otherwise forward + // the arg to the API (e.g. `claw prompt --help`) should show + // top-level help instead. Subcommands that consume their own + // args (agents, mcp, plugins, skills) and local help-topic + // subcommands (status, sandbox, doctor) must NOT be intercepted + // here — they handle --help in their own dispatch paths. + wants_help = true; + index += 1; + } "--version" | "-V" => { wants_version = true; index += 1;