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

[BUG] Prompt.confirm default #170

Closed
ewels opened this issue Jul 23, 2020 · 4 comments
Closed

[BUG] Prompt.confirm default #170

ewels opened this issue Jul 23, 2020 · 4 comments

Comments

@ewels
Copy link
Contributor

ewels commented Jul 23, 2020

Describe the bug
This isn't exactly a bug, but rather some unexpected behaviour with Confirm.ask().

In some situations I would like to confirm something with the user, but set the default response to Yes instead of No. I thought I'd just stick in a default=True argument to the function to see what happens, and it kind of works 😅 Hitting enter gives the default response. The problem is that the default is shown in brackets but the [y/N] suffix remains unchanged, instead of being [Y/n].

This isn't really a problem for me - I'll just not specify a default (I actually prefer requiring an explicit response, but I was converting from click.confirm() which always has a default). I just thought I'd flag the behaviour.

Feel free to close if it's a feature and not a bug 😄

To Reproduce

from rich.prompt import Confirm
if Confirm.ask("Do you like rich?", default=True):
  print("Is the correct answer!")
else:
  print("Boo")
$ python test.py
Do you like rich? [y/N] (True):
Is the correct answer!

Platform

  • Rich 3.4.0
  • iTerm2
  • Mac OSX
@willmcgugan
Copy link
Collaborator

Ah. I copied this from click, and did wonder why it was capitalized that way, but it didn't occur to me the upper case letter was the default. Obvious now.

I don't find that terribly intuitive. Perhaps its because it's the first time I've seen that convention. How about leaving the choices lower case, but putting the default in text form in braces. Like this:

Do you like rich? [y/n] (y)

@ewels
Copy link
Contributor Author

ewels commented Jul 23, 2020

Works for me 👍🏻 Agree that this is more explicit and clear (I don't love the click convention either)

@willmcgugan
Copy link
Collaborator

Fixed in v4.0.0

@ewels
Copy link
Contributor Author

ewels commented Jul 23, 2020

Brilliant stuff - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants