Adding a Reusable Confirmation Prompt Helper#233
Merged
Jordan231111 merged 2 commits intomainfrom Mar 30, 2026
Merged
Conversation
Jordan231111
approved these changes
Mar 30, 2026
Owner
Jordan231111
left a comment
There was a problem hiding this comment.
I pushed a follow-up fix to keep this within issue #209’s scope while making it production-ready.
Problems in the original version:
cargo clippy --all-targets --all-features -- -D warningsfailed becauseparse_answerlived after the test module.- The helper was not exposed through the shared
utilssurface, so it was not actually reusable by the future remove/restore handlers this issue is meant to support. - The
Force(pub bool)wrapper added complexity without improving call sites. - The tests mostly exercised the parser in isolation, not the real prompt path or error handling.
Fixes applied:
- Simplified the API to
confirm(prompt, force: bool). - Kept the prompt logic injectable internally so the real confirmation path is testable without touching global stdin/stdout.
- Re-exported the helper from
utilsso the future CLI handlers can consume it via the intended shared-helper surface. - Added focused tests for accepted answers, safe default-no behavior, force bypass, and write-error propagation.
- Reformatted and reran the full strict validation plus the PR-specific review commands.
Validation run after the fix:
./scripts/validate_strict.sh .review-commands.txt- Included baseline fmt/clippy/all-target/all-features tests, ignored tests, doctests,
cargo test confirmation, and the relevant CLI help/argument checks for remove/remove-file/restore.
With those fixes in place, this is now a clean, low-risk helper change that fits the repo’s current roadmap boundaries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added a simple reusable confirmation so that destructive CLI commands share the same prompt behaviour.
Related Issue
Fixes #209
Type of Change
How to Test
cargo test confirmation
Checklist
cargo fmt+cargo clippy)cargo test)