From bff370003bc2ad71c7b085566e24a3764afb9e7f Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 27 May 2026 15:04:03 +0900 Subject: [PATCH] fix: plugins extra-arg errors now return non-null hint via newline-delimited usage string Parity with #791 (config extra-arg fix). The plugins arg parser emitted 'unexpected extra arguments after claw plugins show ...' with no newline delimiter, so split_error_hint returned None. Added usage hint after newline. 60 CLI contract tests pass. --- rust/crates/rusty-claude-cli/src/main.rs | 3 +- .../tests/output_format_contract.rs | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index a6510fa7..cd0e2ae7 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -1185,8 +1185,9 @@ fn parse_args(args: &[String]) -> Result { let action = tail.first().cloned(); let target = tail.get(1).cloned(); if tail.len() > 2 { + // #797: append \n usage hint so split_error_hint extracts it (parity with #791 config fix) return Err(format!( - "unexpected extra arguments after `claw {} {}`: {}", + "unexpected extra arguments after `claw {} {}`: {}\nUsage: claw plugins [list|show |install |enable |disable |uninstall |update |help]", rest[0], tail[..2].join(" "), tail[2..].join(" ") diff --git a/rust/crates/rusty-claude-cli/tests/output_format_contract.rs b/rust/crates/rusty-claude-cli/tests/output_format_contract.rs index 95feab72..21e821fd 100644 --- a/rust/crates/rusty-claude-cli/tests/output_format_contract.rs +++ b/rust/crates/rusty-claude-cli/tests/output_format_contract.rs @@ -3373,3 +3373,48 @@ fn skills_show_extra_positional_arg_returns_unexpected_extra_796() { "hint should reference usage (#796)" ); } + +#[test] +fn plugins_extra_args_have_non_null_hint_797() { + // #797: `claw plugins show ` returned unexpected_extra_args + hint:null. + // The plugins arg parser at the top level emitted "unexpected extra arguments after + // `claw plugins show ...`: ..." with no \n delimiter. Parity with #791 config fix. + let root = unique_temp_dir("plugins-extra-args-797"); + fs::create_dir_all(&root).expect("temp dir"); + std::process::Command::new("git") + .args(["init", "-q"]) + .current_dir(&root) + .output() + .ok(); + + let output = run_claw( + &root, + &[ + "--output-format", + "json", + "plugins", + "show", + "some-plugin", + "extra-arg", + ], + &[], + ); + assert!( + !output.status.success(), + "plugins show with extra arg must exit non-zero (#797)" + ); + let stderr = String::from_utf8_lossy(&output.stderr); + let j: serde_json::Value = stderr + .lines() + .find(|l| l.trim_start().starts_with('{')) + .and_then(|l| serde_json::from_str(l).ok()) + .expect("plugins extra arg should emit JSON error"); + assert_eq!(j["error_kind"], "unexpected_extra_args"); + let h = j["hint"] + .as_str() + .expect("unexpected_extra_args must have non-null hint (#797)"); + assert!( + h.contains("plugins") || h.contains("Usage"), + "hint should reference plugins usage, got: {h:?}" + ); +}