Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require typed answer for confirm #426

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Celina1801
Copy link

@Celina1801 Celina1801 commented Jan 27, 2025

What is the problem that this PR addresses?

Closes #312
The confirm prompt currently allows users to bypass input by pressing "Enter," which automatically selects the default value. This behavior is problematic for critical confirmations (e.g., deleting files), where explicit user input (e.g., "y" or "n") should be required to ensure intentionality.

How did you solve it?

I introduced a mandatory parameter to the confirm prompt. When mandatory=True, the prompt enforces explicit user input ("y" or "n") and rejects empty or invalid inputs. The implementation modifies the key bindings to re-prompt the user until a valid response is provided.

Unit tests were added to ensure that:

Empty inputs are rejected when mandatory=True.
Valid responses ("y," "n," "Y," "N") are accepted.
Invalid inputs re-prompt the user for confirmation.

Checklist

  • I have read the Contributor's Guide.
  • I will check that all automated PR checks pass before the PR gets reviewed.

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.

Require typed answer for confirm question
1 participant