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

Auto expanding the expand prompt #162

Closed
garymh opened this issue Apr 2, 2021 · 2 comments
Closed

Auto expanding the expand prompt #162

garymh opened this issue Apr 2, 2021 · 2 comments

Comments

@garymh
Copy link

garymh commented Apr 2, 2021

Are you in the right place?

  • For issues or feature requests file a GitHub issue in this repository
  • For general questions or discussion post in Gitter

Describe the problem

I would love to be able to auto bring up the help menu automatically when using the expand prompt. For example, something like:

choices = [{ key: "y", name: "Overwrite", value: :yes }, { key: "n", name: "Skip", value: :no }, { key: "a", name: "Overwrite all", value: :all }]
prompt.expand("Action?", choices, auto_expand: true)

would result in:

Action?
  y - Overwrite
  n - Skip
  a - Overwrite all
  Choice [y]:

The specific use case I have in mind is to have a mix of numbers and letters for options for the prompt- 1, 2, 3, "A", "B", etc. I suppose the same thing could be accomplished with #151 too 😄

I love the gem, btw!

Describe your environment

  • OS version: macOS 11.2.3
  • Ruby version: 2.7.2
  • TTY::Prompt version: 0.23.0
@piotrmurach
Copy link
Owner

Hi Gary 👋

Thanks for using tty-prompt.

This feels to me to go against the spirit of expand prompt, e.i. a compact way to express a choice. Though I'll need to think about whether or not the :auto_expand option makes for a desirable change in the context of other prompts. Your needs would probably be much better served by the select prompt. However, as you rightly pointed out the support for specifying keys is not implemented yet. Please feel free to submit PR and let's take it from there.

@garymh
Copy link
Author

garymh commented Apr 2, 2021

Thanks Piotr! I'll definitely look into that if I get some time 😄

@garymh garymh closed this as completed Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants