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

Adding a new List prompt #118

Closed
ryfu-msft opened this issue Jun 7, 2021 · 4 comments · Fixed by #124
Closed

Adding a new List prompt #118

ryfu-msft opened this issue Jun 7, 2021 · 4 comments · Fixed by #124
Labels
enhancement New feature or request

Comments

@ryfu-msft
Copy link
Contributor

Hey @shibayan,

I had a idea to build a List form input that would take in values and append them to an existing list. For example:

What would you like to add to your grocery list? : Banana

  • Apple
  • Orange

Pressing ENTER would append Banana to the end of this list and ask again.

What would you like to add to your grocery list? :

  • Apple
  • Orange
  • Banana

If the user presses ENTER without any value, the prompt would end.

Please let me know what you think and if you like it, I would like to try working on this.

@shibayan shibayan added the enhancement New feature or request label Jun 8, 2021
@shibayan
Copy link
Owner

shibayan commented Jun 8, 2021

I'm a little confused about how it works, is it an additional feature to Prompt.Select?

@ryfu-msft
Copy link
Contributor Author

It could be an additional feature to Prompt.Select or a standalone prompt. My thinking was that it could address the scenario where a single question requires multiple inputs from the user. Rather than trying to list all the inputs in a single line response, it would append multiple responses to a list that a user could see.

@shibayan
Copy link
Owner

shibayan commented Jun 16, 2021

I understand most of it. I will present the code based on my understanding.

// Accept Prompt.Input like user-input
// typeof(picked) == IEnumerable<string>
var picked = Prompt.List<string>("Please add item(s)", minimum: 1, maximum: 3);

Cobsole.WriteLine(string.Join(",", picked));

@palenshus
Copy link

That looks good! Hopefully we'd still be able to pass IList<Func<object, ValidationResult>> validators as well, which could internally be applied to each item in the enumerable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants