Skip to content

[core] Add confirmation option (--yes / -y)#26

Merged
forfudan merged 3 commits intomainfrom
update
Mar 12, 2026
Merged

[core] Add confirmation option (--yes / -y)#26
forfudan merged 3 commits intomainfrom
update

Conversation

@forfudan
Copy link
Owner

@forfudan forfudan commented Mar 12, 2026

This PR adds confirmation_option() and confirmation_option"prompt" builder methods on Command. When enabled, auto-registers --yes/-y flag and prompts the user for confirmation after parsing. Passing --yes or -y skips the prompt. Aborts on decline or non-interactive stdin.

Changes:

  • Implement Command.confirmation_option() and Command.confirmation_option["prompt"]() plus a post-parse _confirm() step.
  • Add a new test suite covering confirmation behavior and integrate it into the test task.
  • Document the new feature in the user manual and changelog/planning docs.

Add confirmation_option() and confirmation_option["prompt"]() builder
methods on Command. When enabled, auto-registers --yes/-y flag and
prompts the user for confirmation after parsing. Passing --yes or -y
skips the prompt. Aborts on decline or non-interactive stdin.

Equivalent to Click's confirmation_option decorator.

- 13 new tests in tests/test_confirmation.mojo
- Update user manual, changelog, planning doc
- 526 tests across 18 files, all passing
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a Click-style confirmation prompt feature to ArgMojo commands, enabling destructive commands to require an explicit interactive confirmation unless the user passes --yes/-y.

Changes:

  • Implement Command.confirmation_option() and Command.confirmation_option["prompt"]() plus a post-parse _confirm() step.
  • Add a new test suite covering confirmation behavior and integrate it into the test task.
  • Document the new feature in the user manual and changelog/planning docs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/argmojo/command.mojo Adds confirmation-related fields, builder methods, and a _confirm() hook into parse_arguments().
tests/test_confirmation.mojo Introduces tests for --yes/-y skipping and non-interactive abort behavior, plus integration scenarios (subcommands/parents/prompt).
pixi.toml Adds the new confirmation tests to the pixi run test pipeline (run with stdin redirected).
docs/user_manual.md Documents confirmation option usage, API references, and examples.
docs/changelog.md Notes the new confirmation option feature in unreleased changes.
docs/argmojo_overall_planning.md Marks confirmation as complete and updates the test/docs feature matrix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@forfudan forfudan merged commit e3aabcf into main Mar 12, 2026
2 checks passed
@forfudan forfudan deleted the update branch March 12, 2026 22:10
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.

2 participants