MCPcopy Index your code
hub / github.com/pterm/pterm / selectOption

Method selectOption

interactive_multiselect_printer.go:341–359  ·  view source on GitHub ↗
(optionText string)

Source from the content-addressed store, hash-verified

339}
340
341func (p *InteractiveMultiselectPrinter) selectOption(optionText string) {
342 idx := p.findOptionByText(optionText)
343 if idx < 0 {
344 return
345 }
346
347 if p.isSelected(optionText) {
348 // Remove from selected options
349 for i, selectedOption := range p.selectedOptions {
350 if p.Options[selectedOption] == optionText {
351 p.selectedOptions = append(p.selectedOptions[:i], p.selectedOptions[i+1:]...)
352 break
353 }
354 }
355 } else {
356 // Add to selected options
357 p.selectedOptions = append(p.selectedOptions, idx)
358 }
359}
360
361func (p *InteractiveMultiselectPrinter) renderSelectMenu() string {
362 var content strings.Builder

Callers 1

ShowMethod · 0.95

Calls 2

findOptionByTextMethod · 0.95
isSelectedMethod · 0.95

Tested by

no test coverage detected