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
Update InteractiveMultiselectPrinter
to optionally show selected options
#621
Labels
proposal
Proposal to add a new feature to pterm
proposal-accepted
Proposals which are accepted for implementation in the future
Comments
prnvbn
changed the title
Update MultiSelectPrinter to optionally show selected options
Update Jan 22, 2024
InteractiveMultiselectPrinter
to optionally show selected options
MarvinJWendt
added
the
proposal-accepted
Proposals which are accepted for implementation in the future
label
Jan 23, 2024
I agree, that would be nice. |
Great! I will send a PR across :) |
8 tasks
PR ready for review - #625 |
Hey! I'm new to pterm, but doesn't *I may be confused, but I could not find a proper description of this option. If that's the case, I would like to help with this PR Let me show you my junior example of this implementation. Let's say we are building CLI in order to choose web components: componentNames := []string{}
selectedComponentNames := []string{}
for i := range components {
name := components[i].Name
selected := IsSelectedFunc(config, selectedPageName, name) //check if it's already selected
if selected {
selectedComponentNames = append(selectedComponentNames, name)
}
componentNames = append(componentNames, name)
}
printer := pterm.DefaultInteractiveMultiselect.
WithOptions(componentNames).
WithDefaultOptions(selectedComponentNames).
WithFilter(false)
selectedOptions, err := printer.Show()
if err != nil {
panic(err)
}
// Reset chosen components
page := config.Pages[selectedPageName]
page.Components = make(map[string]Component)
config.Pages[selectedPageName] = page
// Add selected components to the page
for i := range selectedOptions {
var selectedOption string = selectedOptions[i]
addComponent(config, config.Pages[selectedPageName], selectedOption)
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
proposal
Proposal to add a new feature to pterm
proposal-accepted
Proposals which are accepted for implementation in the future
When selecting multiple options, it will be useful for the end user of the terminal app to see the options that have been selected so far.
The text was updated successfully, but these errors were encountered: