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

Feature Suggestion: allow "other" option in list input #370

Closed
queengooborg opened this issue Mar 12, 2023 · 3 comments
Closed

Feature Suggestion: allow "other" option in list input #370

queengooborg opened this issue Mar 12, 2023 · 3 comments

Comments

@queengooborg
Copy link

queengooborg commented Mar 12, 2023

This was also requested for inquirer.js -- see SBoudrias/Inquirer.js#1198

I'm utilizing inquirer for a command line script to generate pull requests (including titles and descriptions) for MDN's BCD repository, and first of all, I must say: kudos to the dev team here! I've always enjoyed the original inquirer.js for CLI prompts, and am happy to see a port to Python available!

As a part of one of my questions within the script, I inquire a reason from the user, which is a list of preset entries, as well as an "Other" entry. In this script, I then check to see if "Other" was selected, and if so, prompt the user for a text input to describe the reason. This looks something like so:

reason = inquirer.list_input(
  message="Why is this feature being removed?",
  choices=['Irrelevant', 'Non-Interface', 'Other']
)
if reason == "Other":
  reason = inquirer.text("Why is this feature being removed?")
[?] Why is this feature being removed?: Other
   Irrelevant
   Non-Interface
 > Other

[?] Why is this feature being removed?: I just don't like this feature... >:(

I think it would be nice to have an other option (or something similar), that adds an option to the end which doubles as a text input, like so:

reason = inquirer.list_input(
  message="Why is this feature being removed?",
  choices=['Irrelevant', 'Non-Interface'],
  other="Other Reason" # default: false, setting to "true" will add "Other"
)

# ...or...

reason = inquirer.list_input(
  message="Why is this feature being removed?",
  choices=['Irrelevant', 'Non-Interface', inquirer.list_choice_other('Other Reason')],
)
[?] Why is this feature being removed?: Irrelevant
 > Irrelevant
   Non-Interface
   Other

...or...

[?] Why is this feature being removed?: 
   Irrelevant
   Non-Interface
 > Other: 

...or...

[?] Why is this feature being removed?: I just don't like this feature... >:(
   Irrelevant
   Non-Interface
 > Other: I just don't like this feature... >:(
@Cube707
Copy link
Collaborator

Cube707 commented Mar 12, 2023

Does #256 implement what your looking for? This is already merged

@queengooborg
Copy link
Author

Oh awesome, I hadn't seen this PR! I thought I searched through PRs as well, whoops -- I didn't see anything in the documentation regarding this option (note: the magmax.com URL is a 404)!

@Cube707
Copy link
Collaborator

Cube707 commented Mar 12, 2023

Yea ist a mess too look through PRs with all the dependabot stuff...

And good to know that the documentation is down, i will need to fix that. (See #231)

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