Skip to content

Adding a Reusable Confirmation Prompt Helper#233

Merged
Jordan231111 merged 2 commits intomainfrom
MichaelWang/force-command
Mar 30, 2026
Merged

Adding a Reusable Confirmation Prompt Helper#233
Jordan231111 merged 2 commits intomainfrom
MichaelWang/force-command

Conversation

@ProfessorSen0
Copy link
Copy Markdown
Collaborator

@ProfessorSen0 ProfessorSen0 commented Mar 30, 2026

Description

Added a simple reusable confirmation so that destructive CLI commands share the same prompt behaviour.

Related Issue

Fixes #209

Type of Change

  • Bug fix
  • New feature
  • Refactoring / CI / Docs
  • Other

How to Test

cargo test confirmation

Checklist

  • Code follows project style (cargo fmt + cargo clippy)
  • Tests added/updated and passing (cargo test)
  • Documentation updated (if applicable)

Copy link
Copy Markdown
Owner

@Jordan231111 Jordan231111 left a comment

Choose a reason for hiding this comment

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

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 warnings failed because parse_answer lived after the test module.
  • The helper was not exposed through the shared utils surface, 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 utils so 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.

@Jordan231111 Jordan231111 merged commit 57574fd into main Mar 30, 2026
14 checks passed
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.

MVP Shared: add reusable confirmation prompt helper for restore/remove flows

2 participants