mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-04-25 13:44:06 +08:00
## What Was Broken
`claw init foo` silently accepted the `foo` argument instead of rejecting it at parse time:
$ claw init foo
Init
Project /path/to/project
.claw/ skipped
Trailing args should be rejected like other no-arg verbs (status, sandbox, etc.):
$ claw status bar
[error-kind: cli_parse]
error: unrecognized argument `bar` for subcommand `status`
## Root Cause
The `init` arm (main.rs:1191) was missing a `rest.len()` guard.
Compare to `status` (main.rs:1319 in parse_diagnostic_verb), which correctly
rejects extra args.
## What This Fix Does
Add a simple length guard before constructing the CliAction::Init:
"init" => {
if rest.len() > 1 {
return Err(format!(
"unrecognized argument \`{}\` for subcommand \`init\`",
rest[1]
));
}
Ok(CliAction::Init { output_format })
}
## Dogfood Verification
Before:
$ claw init foo
Init
Project /path/to/project
After:
$ claw init foo
[error-kind: cli_parse]
error: unrecognized argument `foo` for subcommand `init`
$ claw init
Init
Project /path/to/project
(continues normally)
## Non-Regression
- `claw init` (no args) still works
- All 180 binary tests pass
- All 466 library tests pass
## Related
- #152 (diagnostic verb suffix guard)
- Follows pattern from parse_diagnostic_verb() guard clauses