Skip to content

Commit 2a2e205

Browse files
committed
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.
1 parent c55c510 commit 2a2e205

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

  • rust/crates/rusty-claude-cli/src

rust/crates/rusty-claude-cli/src/main.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
382382
let mut compact = false;
383383
let mut base_commit: Option<String> = None;
384384
let mut reasoning_effort: Option<String> = None;
385-
let mut rest = Vec::new();
385+
let mut rest: Vec<String> = Vec::new();
386386
let mut index = 0;
387387

388388
while index < args.len() {
@@ -391,6 +391,31 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
391391
wants_help = true;
392392
index += 1;
393393
}
394+
"--help" | "-h"
395+
if !rest.is_empty()
396+
&& matches!(
397+
rest[0].as_str(),
398+
"prompt"
399+
| "login"
400+
| "logout"
401+
| "version"
402+
| "state"
403+
| "init"
404+
| "export"
405+
| "commit"
406+
| "pr"
407+
| "issue"
408+
) =>
409+
{
410+
// `--help` following a subcommand that would otherwise forward
411+
// the arg to the API (e.g. `claw prompt --help`) should show
412+
// top-level help instead. Subcommands that consume their own
413+
// args (agents, mcp, plugins, skills) and local help-topic
414+
// subcommands (status, sandbox, doctor) must NOT be intercepted
415+
// here — they handle --help in their own dispatch paths.
416+
wants_help = true;
417+
index += 1;
418+
}
394419
"--version" | "-V" => {
395420
wants_version = true;
396421
index += 1;

0 commit comments

Comments
 (0)