JEG2 / highline

A higher level command-line oriented interface.
Other
1.29k stars 137 forks source link

Have to set convert type in order for `.in` to work with array #249

Closed esotericpig closed 1 year ago

esotericpig commented 2 years ago

If you do this, no validation happens:

ask('Letter a, b, or c? ') { |q| q.in = %w[ a b c ] }

You can enter in d, and it accepts the input.

In order for it to work, you have to pass in String:

ask('Letter a, b, or c? ',String) { |q| q.in = %w[ a b c ] }

Is there another way I should do this (I don't want a full-blown menu like with choose)? Else, I think it'd be useful to change it.