Repository navigation
feat(cli): greet bare voltage and name next steps on a terminal - #112
Conversation
ebf8217 to
5bcf94b
Compare
5bcf94b to
d819684
Compare
tee8z
left a comment
There was a problem hiding this comment.
Requesting changes on d819684 (base #111). Off a terminal, or with --json or -o json|ndjson, bare voltage still prints usage to stderr and exits 2. --help, --version and named commands are unchanged. The greeting makes no network request and shows no secret, and its text is scrubbed.
P2: the greeting says "Not signed in" and suggests voltage login for every credential problem. signed_in (src/greeting.rs:50) is false whenever credential_problem is set, and the next step is then always voltage login (:84). But CredentialProblem also covers these:
MultipleCredentials: two saved logins and no default, common with staging and production. The next step is--account NAMEor a profile.EmptyApiKey: a blankVOLTAGE_API_KEYstill overrides saved logins, so the fix is to unset it, andvoltage logincannot help.BoundElsewhereandAuthUrlMismatch.
Key the line and the next step off the problem, as voltage context does, and add a test for at least MultipleCredentials and EmptyApiKey.
Nonblocking:
- The
› Use it:hint afterprofiles createchecks onlydecorates(), notout.is_human(), so it prints with--jsonand with redirected stdout, althoughoutput.mdsays redirected output never has hints. It also prints before the result, and it drops a--config-dirthat was passed. - An empty
payments list --statuses failedsuggests "Receive a payment", whatever filters were given. greeting::showfailing, for examplevoltage --profile missingon a terminal, is untested.
Gate and CRAP on this head are running, and I will add the results.
|
Gate results for |
d819684 to
d3c90f4
Compare
|
Review-body items, in d3c90f4:
|
d3c90f4 to
e1d6055
Compare
voltage with no command, on a terminal, shows the wordmark, who is signed in (from the configuration, without a network request), the saved profile, organization, and wallet, and three commands to try, and exits 0. Off a terminal or with --json it stays a usage error with exit code 2. On a terminal, an empty wallets, payments, or webhooks list ends with a line naming the command that makes the first one, and profiles create names a command that uses the new profile.
e1d6055 to
05d5fd4
Compare
tee8z
left a comment
There was a problem hiding this comment.
Approved 05d5fd4 against feat/cli-look-12-watch (#111 5c45231). My findings are fixed:
- P2, credential problems: the greeting runs
auth::select, the function commands andvoltage contextuse, which reads only the configuration and environment. On a problem it leads withCredentialProblem::error's message, and its first suggestion is that problem's own hint. Unit tests coverNoCredential,EmptyApiKey(unset the variable) andMultipleCredentials(--account NAME or --profile NAME). With no problem and no account, the credential can only beVOLTAGE_API_KEY, so that line is accurate. › Use it:hint: it is now aNextStepthatOutput::suggestwrites after the result. It needs human output on interactive stdout and stderr, with no--output-fileand no--quiet, and it keeps--config-dir. The integration test covers the order,--json,--quietand redirected stdout.- Empty filtered list: the empty-list hint needs no filters and no
--query, and a unit test checks that each suggested command parses. greeting::showfailing:a_greeting_that_cannot_read_its_scope_reports_the_errorcovers it.
Validation on this head, in nix develop: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo machete --with-metadata, cargo test --locked (197 unit, 149 integration) and python3 scripts/check-coverage.py passed. CI is green. I did not run the CRAP report for this re-review.
Stack position: 13 of 13, the last in the look-and-feel stack. Base:
feat/cli-look-12-watch(#111).Problem
Bare
voltagedumped 67 lines of usage to stderr and failed with exit code 2, which is a cold first contact. After a step that leaves you somewhere new (an empty list, a fresh profile), the CLI did not say what to do next.Behavior
voltagewith no command, on a terminal, perhaps with global flags such as--profileor--account:voltage context), never the network, and exits 0.! Not signed inand suggestsvoltage loginfirst when no credential is selected, or✓ Using the API key in VOLTAGE_API_KEYfor an ambient key.--json/--output json|ndjson, nothing changes: usage on stderr, exit code 2.Next steps on a terminal (
--quiethides them; redirected output never has them):wallets list› Create a wallet: voltage wallets create --helppayments list› Receive a payment: voltage payments receive --helpwebhooks list› Create a webhook: voltage webhooks create --helpprofiles create NAME› Use it: voltage wallets list --profile NAME(shell-quoted)The suggestions point at
--helpinstead of guessing placeholder flags. Creating a wallet, for example, needs a credit line and network that only the person knows.Design notes
GlobalFlags::without_commanddetects "no command": clap's missing-subcommand errors, both for no arguments at all and for flags without a command. It then reads the same flags by parsing them in front ofcontext, so the greeting honors--profile,--account,--config-dir, and the staging wrapper's flags.greeting::wantedadds the TTY and machine-output checks, andstartup::rungreets before normal parsing.greeting::linesis pure overvoltage context's JSON plus the account's saved email, so it's tested directly.empty_list_next_stepmaps the three list operations to their hint, andCall::suggestwrites it.strip_stylesnow strips any CSI sequence, not only SGR. It panicked on a status line's trailingESC[2K.Try it on staging
Setup: Try a pull request on staging (added by #97). Read-only, except
profiles create, which saves a local profile.Expect: the bolt wordmark,
✓ Signed in as …, the organization from your.env, thenTryand three›commands.echo $?prints 0.Expect: the old usage error both times, exit code 2.
Expect: if you have no webhooks,
No results.followed by› Create a webhook: voltage webhooks create --help.Expect:
› Use it: voltage wallets list --profile try-itafter the create. The delete removes the profile again. GetORG_IDandENV_IDfromvoltage context --account me.Validation
cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo machete --with-metadata,cargo test --locked(176 unit and 136 integration tests), andpython3 scripts/check-coverage.pyall pass.voltage loginfirst), and an ambient API key.without_commandreads bare and--profileflags, keeps--json, and rejects a named command,--help, and an unknown flag.voltagestill exits 2 with the usage error.wallets listgets the hint, a non-empty one doesn't, andprofiles creategets its› Use itline.--account me.src/cli.rsendpoint, unchanged from feat(cli): follow payments live with payments list --watch #111).greeting.rsis at most 7.0.Docs
docs/getting-started.md,docs/reference/output.md, andCHANGELOG.md.