mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-26 23:46:45 +00:00
fix(#752): cli_parse unrecognized-arg errors now emit non-null hint for all subcommands
This commit is contained in:
@@ -7669,3 +7669,5 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
|
||||
750. **`claw prompt --output-format json` (no text argument) returned `error_kind:"unknown"` and `hint: null`** — dogfooded 2026-05-26 on `2dfb7af6`. The error string `"prompt subcommand requires a prompt string"` had no prefix prefix for classifier and no `\n` for hint extraction. Fix: (a) prefix with `"missing_prompt: "` + newline before usage hint; (b) add `message.starts_with("missing_prompt:")` → `"missing_prompt"` classifier arm. Result: `error_kind:"missing_prompt"`, `hint:"Usage: claw prompt <text> or echo '<text>' | claw"`. Source: Jobdori dogfood on `2dfb7af6`, 2026-05-26.
|
||||
|
||||
751. **ROADMAP #750 has no regression test: `claw prompt --output-format json` no-arg `error_kind` and `hint` could silently regress** — confirmed by gaebal-gajae on `ac925ed4`. Fix: add `prompt_no_arg_json_error_kind_750` test asserting nonzero exit, `error_kind:"missing_prompt"`, non-empty `hint` mentioning `claw prompt` or `echo`. Source: gaebal-gajae dogfood on `ac925ed4`, 2026-05-26.
|
||||
|
||||
752. **`claw <subcommand> --output-format json <bogus-arg>` returned `hint: null` for all `cli_parse` errors when an unrecognized positional arg was supplied** — dogfooded 2026-05-26 on `ddc71b56`. Generic `unrecognized argument` format string had no `\n` so `split_error_hint` emitted null hint (only the `--json` special-case added a hint). Fix: add else-branch appending `\nRun `claw <verb> --help` for usage.` to the generic arm. Affected surfaces: `sandbox`, `doctor`, `version`, and any other subcommand routing through the same unrecognized-arg path. Source: Jobdori dogfood on `ddc71b56`, 2026-05-26.
|
||||
|
||||
@@ -1326,6 +1326,9 @@ fn parse_single_word_command_alias(
|
||||
// Hint at the correct flag so they don't have to re-read --help.
|
||||
if rest[1] == "--json" {
|
||||
msg.push_str("\nDid you mean `--output-format json`?");
|
||||
} else {
|
||||
// #752: generic fallback hint so cli_parse errors always have non-null hint
|
||||
msg.push_str(&format!("\nRun `claw {} --help` for usage.", verb));
|
||||
}
|
||||
return Some(Err(msg));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user