This PR makes the following three notable changes to the bullet.client.YesNo class.
Fixes a bug so that when default='y' is specified, the .launch() method returns True.
Reproduction steps below
Makes the prompt prefix an optional keyword argument to YesNo.__init__. This specifically will let users remove if they'd like or set it to something like [Y/n] to make the default obvious.
Supports answers of full "Yes" and "No" for users that like to be explicit. Technically "Ye" will evaluate to yes since there's no overlap with No.
Demonstration
In [1]: import bullet
In [2]: bullet.YesNo('Are you hungry? ').launch(default='y')
[y/n] Are you hungry?
Out[2]: True
In [3]: bullet.YesNo('Are you hungry? ').launch(default='y')
[y/n] Are you hungry? yes
Out[3]: True
In [4]: bullet.YesNo('Are you hungry? ').launch(default='y')
[y/n] Are you hungry? no
Out[4]: False
In [5]: bullet.YesNo('Are you hungry? ').launch(default='y')
[y/n] Are you hungry? n
Out[5]: False
In [6]: bullet.YesNo('Are you hungry? [Y/n] ', prompt_prefix='').launch(default='y')
Are you hungry? [Y/n]
Out[6]: True
Bug Reproduction / Demonstration
In [1]: import bullet
In [2]: bullet.YesNo('Are you hungry? ').launch(default='y')
[y/n] Are you hungry?
Out[2]: False
This PR makes the following three notable changes to the
bullet.client.YesNo
class.default='y'
is specified, the.launch()
method returnsTrue
.YesNo.__init__
. This specifically will let users remove if they'd like or set it to something like[Y/n]
to make the default obvious.Demonstration
Bug Reproduction / Demonstration
Thanks!