Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

fix: #127 reject unrecognized suffix args for diagnostic verbs

YeonGyu-Kima3270db602a7
diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs
index 738d7c59..b652cf48 100644
--- a/rust/crates/rusty-claude-cli/src/main.rs
+++ b/rust/crates/rusty-claude-cli/src/main.rs
@@ -746,6 +746,31 @@ fn parse_single_word_command_alias(
permission_mode_override: Option<PermissionMode>,
output_format: CliOutputFormat,
) -> Option<Result<CliAction, String>> {
+ if rest.is_empty() {
+ return None;
+ }
+
+ // Diagnostic verbs (help, version, status, sandbox, doctor, state) accept only the verb itself
+ // or --help / -h as a suffix. Any other suffix args are unrecognized.
+ let verb = &rest[0];
+ let is_diagnostic = matches!(
+ verb.as_str(),
+ "help" | "version" | "status" | "sandbox" | "doctor" | "state"
+ );
+
+ if is_diagnostic && rest.len() > 1 {
+ // Diagnostic verb with trailing args: reject unrecognized suffix
+ if is_help_flag(&rest[1]) && rest.len() == 2 {
+ // "doctor --help" is valid, routed to parse_local_help_action() instead
+ return None;
+ }
+ // Unrecognized suffix like "--json"
+ return Some(Err(format!(
+ "unrecognized argument `{}` for subcommand `{}`",
+ rest[1], verb
+ )));
+ }
+
if rest.len() != 1 {
return None;
}