Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to accept multiple selections with .in and .default? #246

Closed
Joshfindit opened this issue Jun 9, 2020 · 5 comments · Fixed by #258
Closed

Possible to accept multiple selections with .in and .default? #246

Joshfindit opened this issue Jun 9, 2020 · 5 comments · Fixed by #258

Comments

@Joshfindit
Copy link

Joshfindit commented Jun 9, 2020

Currently I have

# trimmed: puts menu items

cli.ask("Which number? (0 or <Enter> to skip): ", Integer) { |q|
  q.in = 0..(possibleSelections.length)
  q.default = 0
}

This is awesome for choosing multiple items from a list, such as:

1. TEST1.png
2. TEST2.png
3. TEST3.png
4. TEST4.png
5. TEST5.png
6. TEST6.png
7. TEST7.png

Which number? (0 or <Enter> to skip): 12
Your answer isn't within the expected range (included in 0..7).
?

What I would like to extend to is this:

Which number(s)? (0 or <Enter> to skip): 1, 2, 5
Success

and

Which number(s)? (0 or <Enter> to skip): 1, 2, 5, 12
Your answer isn't within the expected range (included in 0..7).
?

Thanks!

@abinoam
Copy link
Collaborator

abinoam commented Oct 19, 2020

Dear @Joshfindit,

Sorry, for the late answer.

I'm not sure I could understand the problem you have stated correctly.
Could you please clarify it? (Note that I'm not a native english speaker)

Best regards

@abinoam
Copy link
Collaborator

abinoam commented Oct 19, 2020

Perhaps it would be easier for me to understand if you provide a complete code snipped that I could try to run on my machine things.

@rubyFeedback
Copy link

If I understand it correctly he wants to be able to do multiple input on the same line?

not sure if I understood it but the sample he showed was e. g.:

"1, 2, 5, 12"

Can't say so far as I usually have only single selections. :D But this may be
what he is aiming for. In that case probably just a convenience feature to
avoid several newlines for multiple guesses, I suppose?

@abinoam
Copy link
Collaborator

abinoam commented Jan 2, 2023

Hi @Joshfindit

Are you still interested in this feature.
I tried to accomplish it with minimum code change.
I'll open a PR tomorrow.

@Joshfindit
Copy link
Author

Are you still interested in this feature.

I don’t personally have a need for it any more. I still do think there’s general benefit for others.

abinoam added a commit that referenced this issue Jan 2, 2023
Issue #246 - Add custom validation class option to `Question#validate`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants