fix(cli): reject trailing remotes list/remove arguments

Merged
SO
2mo ago
+408-2

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 RemotesArgumentParser for the read/delete verbs;
  • keeps --json as the supported output flag;
  • makes remotes list accept no positional arguments;
  • makes remotes remove accept 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:

  • list with no args and with --json;
  • list with an unknown flag and an extra positional;
  • remove <target> with --json before/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

View with [code]smith Autofix with [code]smith
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 RemotesArgumentParser for the read/delete verbs; --json remains 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 list and remotes remove now provide clearer errors for unknown flags and unexpected extra arguments.
    • remotes list accepts --json without reporting it as an unexpected argument. remotes remove accepts --json before or after the target, while still reporting an error for extra positional arguments.
    • remotes remove accepts targets that begin with a dash when they follow --.