piotrmurach / tty-prompt

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

Choice.from(object) fails #97

Closed ioquatix closed 5 years ago

ioquatix commented 5 years ago

Considering https://github.com/piotrmurach/tty-prompt/blob/00e1b21520f0af030451245c24e79b99e8c3b0b8/lib/tty/prompt/choice.rb#L29-L47

Is there any reason why the default can't be new(val, val) rather than raising an exception?

ioquatix commented 5 years ago

Here is how I used to use it (which worked):

zone = prompt.select("What zone do you want to update?", @connection.zones)
ioquatix commented 5 years ago

I checked and it worked this way from 0.12.x through to at least 0.16.x. The version I tested where it stopped working was 0.18.x.

I think if you supply objects that respond with #to_s it should be okay.

ioquatix commented 5 years ago

Hope this is sufficient, sorry pretty busy today but wanted to contribute to your project, it's awesome, thanks for your kind consideration.