You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
fromrich.promptimportConfirmifConfirm.ask("Do you like rich?", default=True):
print("Is the correct answer!")
else:
print("Boo")
$ python test.pyDo you like rich? [y/N] (True):Is the correct answer!
Platform
Rich 3.4.0
iTerm2
Mac OSX
The text was updated successfully, but these errors were encountered:
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:
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
Platform
The text was updated successfully, but these errors were encountered: