Skip to content

fix(cli): accept --all on environments, organizations, and profiles list - #120

Merged
thebrandonlucas merged 4 commits into
docs/try-pr-on-stagingfrom
brandon/dev-2954-voltage-cli-accept-all-on-environments-list-and-stop
Nov 4, 2026
Merged

thebrandonlucas merged 4 commits into
docs/try-pr-on-stagingfrom
brandon/dev-2954-voltage-cli-accept-all-on-environments-list-and-stop

Conversation

@thebrandonlucas

@thebrandonlucas thebrandonlucas commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

voltage environments list --org ORG --all failed with exit code 2: unexpected argument '--all' found. #94 made API lists without paging, such as wallets list, accept --all and ignore it. The local lists are clap-derived subcommands, not registry operations, so #94 did not reach them. organizations list and profiles list had the same failure.

Change

Command Before After
environments list --all exit 2, unexpected argument accepted, ignored
organizations list --all exit 2, unexpected argument accepted, ignored
profiles list --all exit 2, unexpected argument accepted, ignored
profiles get NAME --all, context --all rejected still rejected
  • src/cli.rs: the --all argument from feat(cli): accept --all on lists that return every item at once #94 moves into all_at_once_arg(). The registry lists and the two local List variants (ListCommand::List, ProfileCommand::List) use it. The help text is now "No effect: this list shows every item at once", which is also true for the local profiles list.
  • Tests: all_is_accepted_by_every_list_command walks the whole command tree and fails if any list subcommand has no --all, so a new list cannot miss it. all_is_ignored_by_local_lists_and_rejected_by_other_local_commands tests the three local lists and the rejection path for local commands that are not lists. Both tests fail without the fix.
  • CHANGELOG.md (Unreleased) and docs/guides/requests.md (Paging) are updated.

About --wallet <UUID> in the usage line

That usage line is not a real requirement. When clap suggests a similar flag (--all → --wallet), Parser::did_you_mean_error in clap_builder 4.6.7 adds the suggested argument to the matches "to build a proper usage string". So the usage line names the suggestion as if it were given. voltage environments list --walle shows the same line. Now that --all is accepted, this command no longer prints that suggestion. The clap behavior for other typos is out of scope here.

Closes #119
Linear: DEV-2954

Try it on staging

Setup: Try a pull request on staging

alias voltage="$PWD/scripts/voltage-staging"
voltage --build
voltage login --account me --credential-store file
voltage organizations list --account me --all

Expect: the same organization table as without --all, exit 0. Before this change: error: unexpected argument '--all' found, exit 2.

voltage environments list --account me --org ORG_ID --all

Use an organization ID from the previous command. Expect: the environment table, exit 0.

voltage profiles list --all
voltage organizations list --help | grep -A1 -- '--all'

Expect: the saved profiles (or an empty list), exit 0; the help shows --all with No effect: this list shows every item at once.

voltage profiles get NAME --all; echo "exit $?"
voltage context --all; echo "exit $?"

Expect: unexpected argument '--all' found and exit 2 for both, because neither is a list.

Checks

Run on the head after merging master (a3bf7cd):

  • cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo machete --with-metadata, cargo test --locked (201 unit + 149 integration tests pass), python3 scripts/check-coverage.py: all pass.
  • I removed the fix and confirmed that both new tests fail.
  • CRAP report (scripts/crap-report.sh, cargo-llvm-cov 0.8.5, knots 1.16.0): 849 of 1060 functions measured, 0 violations. The highest score is 18.10 (src/api.rs wait_for_payment, unchanged). endpoint in src/cli.rs is at 18.00 and this PR does not change it.
  • The voltage-pr-review self-review led to one fix: the help text no longer says "response", because profiles list is local.
  • Staging, with the PR's binary and a browser login: organizations list --all and environments list --org ORG_ID --all exit 0 with their tables, and profiles list --all exits 0. profiles get x --all and context --all are rejected with unexpected argument '--all'. The help shows the new text.
  • Not run: the Windows CI job (no Windows host); CI runs it.

Merge order

#123 (environments create) now sits above this PR in stack #135, and the overlap is resolved: its EnvironmentCommand flattens DiscoveryCommand (from #126), whose list carries all_at_once_arg(), and the merges into #126 and #123 update the environments list --all assertion in all_is_ignored_by_local_lists_and_rejected_by_other_local_commands. all_is_accepted_by_every_list_command passes on every layer. Nothing more is needed here.

Stack

Stack #135, layer 2 of 9 (bottom targets master):

# PR Change
1 #97 Staging setup and a Try it section for each PR
2 #120 (this PR) --all on organizations, environments, and profiles list
3 #128 Warn when a profile or flag overrides a set VOLTAGE_* variable
4 #129 voltage context --format env
5 #127 Replace hand-rolled terminal code with crossterm
6 #126 Pick the wallet, organization, or environment to show
7 #130 Prefilled GitHub issue links from voltage feedback and panics
8 #123 voltage environments create
9 #131 Replace flake.nix with a Kaifile

The layers are chained with merge commits, because history is not rewritten. Use squash and merge, bottom first.

These local lists return every item at once but rejected --all, unlike the
API lists fixed in #94. They now accept it and ignore it, through the same
argument. A test walks the command tree so a new list cannot miss --all.

Closes #119.
tee8z
tee8z previously approved these changes Oct 26, 2026

@tee8z tee8z left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One all_at_once_arg() serves the registry lists and the local lists. The tree walk in all_is_accepted_by_every_list_command keeps a future list from missing --all, and the second test covers the rejection path. The changelog and the Paging docs are updated.

@thebrandonlucas
thebrandonlucas marked this pull request as ready for review October 29, 2026 12:26
…ltage-cli-accept-all-on-environments-list-and-stop

# Conflicts:
#	CHANGELOG.md
@thebrandonlucas
thebrandonlucas changed the base branch from master to docs/try-pr-on-staging November 4, 2026 18:20
thebrandonlucas added a commit that referenced this pull request Nov 4, 2026
…-the-cli' into brandon/dev-2953-voltage-cli-add-environments-create

Resolve environments create against the layers below it:

- EnvironmentCommand flattens DiscoveryCommand (list, get) from #126 and
  adds create, so `environments list` keeps the --all that #120 added and
  `environments get` keeps the picker.
- Resolver::discover keeps #126's DiscoveryCommand argument and uses this
  branch's requires_login and login_organization helpers.
- pick asks for an environment only for `environments get`, and #120's
  parse test matches EnvironmentCommand::Discovery(DiscoveryCommand::List).
- CHANGELOG, docs/commands.md, the login guide, and check-coverage.py keep
  both the get and create entries.

@tee8z tee8z left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 118b143. The code is the same as at my earlier approval (c6318f4); the diff since then comes from the master merges. One all_at_once_arg() serves the registry and local lists, the tree walk keeps a future list from missing --all, and the rejection path is tested.

CRAP on this head: 849 of 1060 functions measured, 0 violations. Highest: 18.10 wait_for_payment (unchanged), then 18.00 endpoint (unchanged). CI is green.

@thebrandonlucas
thebrandonlucas merged commit 1f1ba99 into master Nov 4, 2026
7 checks passed
@thebrandonlucas
thebrandonlucas deleted the brandon/dev-2954-voltage-cli-accept-all-on-environments-list-and-stop branch November 4, 2026 22:59
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.

environments list rejects --all and suggests --wallet

2 participants