mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-30 17:26:44 +00:00
Keep malformed diff invocations with trailing JSON format flags on the parser error path and lock the contract with focused output-format regressions. Constraint: Do not touch tracked .omx state files. Rejected: Repeating direct binary smoke loops | local auth/provider configuration intercepts those invocations and obscures parser behavior. Confidence: high Scope-risk: narrow Tested: git diff --check; cargo fmt --check; cargo test -p rusty-claude-cli diff_extra_args_have_typed_error_kind_and_hint_766 --test output_format_contract; cargo test -p rusty-claude-cli diff_trailing_json_after_malformed_args_is_bounded_json_3129 --test output_format_contract; cargo test -p rusty-claude-cli diff_non_git_dir_has_error_kind_and_hint_801 --test output_format_contract
This commit is contained in:
@@ -1225,10 +1225,10 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
|
||||
// `git diff`). No session needed to inspect the working tree.
|
||||
"diff" => {
|
||||
if rest.len() > 1 {
|
||||
return Err(format!(
|
||||
"unexpected extra arguments after `claw diff`: {}\nUsage: claw diff",
|
||||
rest[1..].join(" ")
|
||||
));
|
||||
// #3129: keep malformed `diff ... --output-format json` on the
|
||||
// parser/error path, not the prompt/TUI fallback. The newline
|
||||
// before Usage is part of the JSON hint contract.
|
||||
return Err(unexpected_diff_args_error(&rest[1..]));
|
||||
}
|
||||
Ok(CliAction::Diff { output_format })
|
||||
}
|
||||
@@ -1625,6 +1625,13 @@ fn removed_auth_surface_error(command_name: &str) -> String {
|
||||
)
|
||||
}
|
||||
|
||||
fn unexpected_diff_args_error(extra: &[String]) -> String {
|
||||
format!(
|
||||
"unexpected extra arguments after `claw diff`: {}\nUsage: claw diff",
|
||||
extra.join(" ")
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_acp_args(args: &[String], output_format: CliOutputFormat) -> Result<CliAction, String> {
|
||||
match args {
|
||||
[] => Ok(CliAction::Acp { output_format }),
|
||||
|
||||
Reference in New Issue
Block a user