Return group in SelectionPrompt and MultiSelectionPrompt
See original GitHub issueIs your feature request related to a problem? Please describe.
I would love when using SelectionPrompt
or MultiSelectionPrompt
with choice groups, that I could get both the selected item, but also the group it belongs to as output.
Consider this code:
var api = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("What API do you want to explore?")
.PageSize(10)
.MoreChoicesText("[grey](Move up and down to reveal more options)[/]")
.AddChoiceGroup("Cloud API", new string []
{
"Booking API"
})
.AddChoiceGroup("Site API", new string[]
{
"Booking API"
}));
If I have the same choice in different groups, I would like to know which group it belongs to.
Right now I would have to wrap the strings in my own little class such as:
public class Choice
{
public string Name { get; set; }
public string Group { get; set; }
public override string ToString() => Name;
}
Describe the solution you’d like A clear and concise description of what you want to happen.
Would be great if somehow SelectionPrompt
and MultiSelectionPrompt
could somehow also return the choice group when returning a value.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Support for Escape key in SelectionPrompt and ...
Basic idea is that prompt ends when user presses Escape key and it somehow indicates to the caller it was cancelled (e.g. by...
Read more >SelectionPrompt/AddChoice use a Tree (put only the text)
I would like to use the tree (text would be enough) to enrich the selection prompt with more information. Can that be achieved...
Read more >Use a multi-selection macro variables from a prompt in pass ...
As you see in the code below, I want to bring back records where the values selected by the prompt are in the...
Read more >Chosen Selector
Multi-Selection Prompt ... How do I create groups of options? ... A group of options is called an “optgroup” and you can define...
Read more >Multiple Dates in Date Range Filter - Data Management
Hi, I would like to use between operator on multi select date parameter. If the date range filter is [date] between start_date and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Cheesebaron I totally get what you’re after, but the problem is that
AddChoiceGroup
is just a convenience method to add a single level to the tree. It’s also possible to build a selection tree with an arbitrary number of levels.The result would need to look something like the code below, which I think would make things more complicated than it should be.
Perhaps we could add a method to the tree itself to get the parent of a choice?
Go ahead, have been busy with other things. So please do take a stab at it.