piotrmurach / tty-prompt

A beautiful and powerful interactive command line prompt
https://ttytoolkit.org
MIT License
1.47k stars 136 forks source link

Set a validator for Yes/No prompt #106

Closed ghost closed 5 years ago

ghost commented 5 years ago

If I type a value that cannot be convert to Boolean will raise a exception:

from /usr/lib/ruby/gems/2.6.0/gems/tty-prompt-0.18.1/lib/tty/prompt/converters.rb:23:in `rescue in on_error'
TTY::Prompt::ConversionError ('2' could not be converted from `string` into `boolean` )

A validator should be set to prevent users from entering other values.

piotrmurach commented 5 years ago

Thanks for reporting. I agree it's better to prevent erroneous input or display error message about invalid input so the user can correct. Can you please submit PR fixing this?

ghost commented 5 years ago

@piotrmurach I am not very familiar your code, I don't necessarily have time recently.I suggest you fix this little issue by yourself.

slowbro commented 5 years ago

i fixed this 'little issue' - pr #114