8000 Return group in SelectionPrompt and MultiSelectionPrompt · Issue #502 · spectreconsole/spectre.console · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Return group in SelectionPrompt and MultiSelectionPrompt #502
Closed
@Cheesebaron

Description

@Cheesebaron

Is 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done 🚀

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0