Skip to content

fix(cycles): --json and --quiet imply --yes in icp cycles buy - #825

Merged
raymondk merged 2 commits into
mainfrom
cycles-buy/01-json-implies-yes
Oct 20, 2026
Merged

raymondk merged 2 commits into
mainfrom
cycles-buy/01-json-implies-yes

Conversation

@raymondk

Copy link
Copy Markdown
Collaborator

icp cycles buy --json and -q now imply --yes.

A machine-readable run has nobody to ask. Before, --json or -q without --yes printed the quote and prompted on a terminal, and refused to create the order without one (a script that forgot --yes failed; 2>&1 | tee with a terminal on stdin died inside the prompt). Now both behave exactly as --yes --json and --yes -q already did: no quote on stderr, no prompt, no refusal, just the stdout data. A plain human run still prompts, and still refuses off a terminal unless --yes is given.

  • consent(args) derives (yes, speak) from the flags; confirm is unchanged.
  • --yes help text says it is implied; cli.md regenerated; guide sentence added.
  • Unit test a_machine_readable_run_implies_yes parses real flag sets through clap; the integration test cycles_buy_reports_a_refunded_order now runs its --json leg without --yes, off a tty.

This replaces the terminal-detection and shorter-question changes of #824 (not wanted).


Part of restacking #824 into small PRs, one fix each, stacked on main in this order: cycles-buy/01-json-implies-yes → 02-arg-group → 03-gateway → 04-qr-colours → 05-paste-flags → then the wait, its follow-up text and the --json fields. Each PR targets the one below it; after the one below merges, retarget to main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Twxau844tMTwyHpQJEbmBo

Copilot AI balanced review requested due to automatic review settings October 16, 2026 22:44
@raymondk
raymondk requested a review from a team as a code owner October 16, 2026 22:44

Copilot AI 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.

🟢 Approval recommended

The focused implementation matches the intended behavior, preserves human confirmation, and includes targeted regression coverage.

No open issues 🎉

What changed in this PR

Makes icp cycles buy --json and --quiet imply --yes, enabling noninteractive use while preserving human-mode confirmation.

Changes:

  • Derives confirmation and quote visibility from output flags.
  • Adds flag-parsing and nonterminal regression coverage.
  • Updates help, documentation, and release notes.
File Description
docs/​reference/​cli.md Documents implied confirmation in CLI help.
docs/​guides/​tokens-and-cycles.md Explains noninteractive flag behavior.
crates/​icp-cli/​tests/​cycles_tests.rs Tests JSON operation without explicit consent.
crates/​icp-cli/​src/​commands/​cycles/​buy.rs Implements implied consent and unit coverage.
CHANGELOG.md Records the behavior change.

Review effort: Balanced

@raymondk
raymondk added this pull request to stack #835 October 20, 2026 15:44
A machine-readable run has nobody to ask. Before, `icp cycles buy --json`
or `-q` without `--yes` printed the quote and prompted on a terminal, and
refused to create the order without one; now both behave as `--yes --json`
and `--yes -q` already did: no quote on stderr, no prompt, no refusal, just
the stdout data. A plain human run still prompts, and still refuses off a
terminal unless `--yes` is given.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Twxau844tMTwyHpQJEbmBo
@raymondk
raymondk force-pushed the cycles-buy/01-json-implies-yes branch from 0a6c7b4 to 4fa363c Compare October 20, 2026 15:45
cargo-deny rejects 49.0.3 for two new Wasmtime advisories,
RUSTSEC-2026-0378 and RUSTSEC-2026-0379; 49.0.4 is the patched release
they name. No code changes.


Claude-Session: https://claude.ai/code/session_01Twxau844tMTwyHpQJEbmBo

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
@raymondk
raymondk merged commit 407d1f6 into main Oct 20, 2026
106 checks passed
@raymondk
raymondk deleted the cycles-buy/01-json-implies-yes branch October 20, 2026 18:48
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.

3 participants