Skip to content

feat(cli): accept a repeated --rack as well as a comma list - #217

Merged
ndbroadbent merged 2 commits into
mainfrom
nathan/repeated-rack-flag
Nov 8, 2026
Merged

ndbroadbent merged 2 commits into
mainfrom
nathan/repeated-rack-flag

Conversation

@ndbroadbent

Copy link
Copy Markdown
Member

Problem

--rack was a plain string flag, so repeating it kept only the last value, with no warning. deploy-approval approve --app web --commit <sha> --rack us --rack eu approved EU alone and left the US request pending. The help only showed the comma form (--rack us,eu), so nothing told the user the first rack had been dropped.

Change

  • --rack collects repeated values (rackFlagValue in internal/cli/rack_flag.go). --rack us --rack eu, --rack us,eu, -r us --rack=eu and mixes like --rack staging --rack us,eu all select the same racks, in the order given. Repeats count once.
  • Deploy approval commands (approve, list, show, wait) act on every rack in the list. all mixed with rack names (--rack all --rack us, --rack all,eu) is now refused with a clear message. It used to fail with No rack found with name "all". --rack all --rack all still means all.
  • Commands that use one rack (ps, run, env, deploy-approval request and the rest) now refuse several racks, from --rack or RACK_GATEWAY_RACK: this command uses one rack, but several were selected: us, eu. Before, a repeated --rack quietly used the last rack, and a comma list failed as an unknown rack named us,eu. Naming one rack twice (--rack us --rack us) is still fine.
  • Login refuses rack names with commas, since --rack could never select them.
  • The help for approve, list, show, wait and the global flag shows both forms. So do the CLI docs (commands, multi-rack, deploy approvals) and internal/cli/AGENTS.md.
  • Execute now builds the root command through newRootCommand(), so tests parse the real global flags.

Tests

internal/cli/rack_flag_test.go parses through the root command's own flags. It covers repeated, short and long, comma, mixed, order, duplicates, blank values, repeated all, all mixed with other racks, single-rack refusal (flag and env), one rack named twice, and login with a comma.

Each test was mutation-checked by breaking the code and watching the test fail. The breaks were: the root flag back to StringVarP, no de-duplication, SelectedRack taking a list, all mixed with other racks allowed, and the login check removed.

go test ./internal/cli/... passes. I also checked a built CLI by hand:

  • ps --rack us --rack eu refuses with the message above.
  • deploy-approval list --rack staging --rack us,eu reads all three racks.
  • --rack all --rack us gets the new error.

Includes the version bump to v0.1.34.

--rack was a plain string flag, so a repeated flag kept only its last value
with no warning: `deploy-approval approve --rack us --rack eu` approved EU
alone and left the US request pending.

--rack now adds each repeated value to the list. `--rack us --rack eu`,
`--rack us,eu` and mixes like `--rack staging --rack us,eu` select the same
racks, in the order given, with repeats dropped. Deploy approval commands
(approve, list, show, wait) act on each one, and `all` mixed with other
racks is refused instead of failing as an unknown rack named "all".

Commands that use one rack now refuse several (from --rack or
RACK_GATEWAY_RACK) rather than quietly using one of them, and login refuses
rack names with commas, which --rack could never select.
@deepsource-io

deepsource-io Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in fed166b...d4a82c4 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Nov 8, 2026 5:16a.m. Review ↗
Go Nov 8, 2026 5:16a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@ndbroadbent
ndbroadbent merged commit e309198 into main Nov 8, 2026
13 checks passed
@ndbroadbent
ndbroadbent deleted the nathan/repeated-rack-flag branch November 8, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant