AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.08k stars 350 forks source link

Add MultiInput prompt #223

Closed eimlav closed 5 years ago

eimlav commented 5 years ago

This commit adds a MultiInput prompt allowing a user to enter multiple distinct values for a question. These are then returned as a []string. For example:

? What are your friend's names?

Then the user is prompted for the first answer, then the second and so on.

? #1: Batman
? #2: Joker
? #3:

Then once finished they enter an empty line and the question will exit, outputting the answers.

? What are your friend's names? [Batman Joker]
eimlav commented 5 years ago

@AlecAivazis I was unable to get TestMultiInputPrompt tests to work. Would you be able to provide some advice on how I could get these working?

AlecAivazis commented 5 years ago

Hey @eimlav - thanks for submitting this.

We've had a few discussions over the years about a prompt like this and ultimately we decided that this a prompt like this is too similar to Input to add to the group. That's not to say its not a useful prompt. The prompts in survey are designed as building blocks for prompts like this one so we try to only add ones that are truly unique.

Sorry about this! I know it can be disappointing to put a bunch of work into something that won't get accepted.

eimlav commented 5 years ago

@AlecAivazis Ah I understand. I'll just make it a part of the package I'm using it in then. At least this saves me from having to write those tests! Thanks for the quick response.