fix(cli): reject trailing remotes list/remove arguments
Summary
Fixes #15873.
cmux remotes list and cmux remotes remove previously ignored trailing flags and positional arguments, so typos could still send a valid socket request and appear successful.
This change:
- extracts a pure
RemotesArgumentParserfor the read/delete verbs; - keeps
--jsonas the supported output flag; - makes
remotes listaccept no positional arguments; - makes
remotes removeaccept exactly one target; - rejects unknown flags and extra positionals before any
remotes.*RPC is sent; - leaves route/socket semantics unchanged.
The regression tests are committed before the fix and exercise accepted and rejected parser forms without a live app or socket.
Testing
Added CLIRemotesArgumentValidationTests to the host-free cmuxCLITests target and wired the pure parser into that target.
Covered:
listwith no args and with--json;listwith an unknown flag and an extra positional;remove <target>with--jsonbefore/after the target;- missing remove target;
- unknown remove flag;
- extra remove positional.
I could not execute the macOS CLI test bundle from this GitHub-only environment, so the PR's exact-head CI remains the execution gate.
Localization audited: no new user-facing strings were introduced; the CLI reuses the existing remotes usage/errors.
AI assistance was used to prepare this contribution.
Changelog
Fixed trailing argument validation for remote list and remove commands.
Demo Video
Not applicable: CLI argument-validation change only.
Checklist
- Behavior changes have added or updated tests
- Localization audited; no new user-facing strings
- New or changed v2 socket method allowlisted for
cmux ssh: not applicable - iOS connectivity/auth/lifecycle/mobile RPC contract change: not applicable
- User-facing docs updated if needed: usage is unchanged
- Reviewed with a subagent before merge; awaiting repository review/CI
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Fixes #15873: cmux remotes list and cmux remotes remove previously ignored trailing flags and extra positional arguments, so typos still sent a valid socket request and appeared successful. Unknown flags and extra positionals are now rejected before any remotes.* RPC is sent.
Bug Fixes
- Extracts a pure
RemotesArgumentParserfor the read/delete verbs;--jsonremains the only supported output flag. remotes list(list/ls) accepts no positional arguments;remotes remove(remove/rm/delete) accepts exactly one target.- Honors the
--terminator: arguments after it are treated as positionals, not flags. - Localizes the rejection errors in eight languages and appends usage text to unknown-flag failures.
- Adds host-free parser tests plus CLI-dispatch integration tests verifying rejected arguments send no registry request; valid route and socket semantics are unchanged.
Summary by CodeRabbit
- Bug Fixes
remotes listandremotes removenow provide clearer errors for unknown flags and unexpected extra arguments.remotes listaccepts--jsonwithout reporting it as an unexpected argument.remotes removeaccepts--jsonbefore or after the target, while still reporting an error for extra positional arguments.remotes removeaccepts targets that begin with a dash when they follow--.