mirror of
https://github.com/charmbracelet/gum
synced 2024-05-24 09:22:24 +02:00
feature(choose): Adding option to use non-matching filter as result (#233)
This commit is contained in:
parent
e38cfdaa10
commit
b0aba2261d
|
@ -87,7 +87,6 @@ func (o Options) Run() error {
|
||||||
return fmt.Errorf("unable to run filter: %w", err)
|
return fmt.Errorf("unable to run filter: %w", err)
|
||||||
}
|
}
|
||||||
m := tm.(model)
|
m := tm.(model)
|
||||||
|
|
||||||
if m.aborted {
|
if m.aborted {
|
||||||
return exit.ErrAborted
|
return exit.ErrAborted
|
||||||
}
|
}
|
||||||
|
@ -103,6 +102,9 @@ func (o Options) Run() error {
|
||||||
fmt.Println(m.matches[m.cursor].Str)
|
fmt.Println(m.matches[m.cursor].Str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !o.Strict && len(m.textinput.Value()) != 0 && len(m.matches) == 0 {
|
||||||
|
fmt.Println(m.textinput.Value())
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ type Options struct {
|
||||||
IndicatorStyle style.Styles `embed:"" prefix:"indicator." set:"defaultForeground=212" envprefix:"GUM_FILTER_INDICATOR_"`
|
IndicatorStyle style.Styles `embed:"" prefix:"indicator." set:"defaultForeground=212" envprefix:"GUM_FILTER_INDICATOR_"`
|
||||||
Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"`
|
Limit int `help:"Maximum number of options to pick" default:"1" group:"Selection"`
|
||||||
NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"`
|
NoLimit bool `help:"Pick unlimited number of options (ignores limit)" group:"Selection"`
|
||||||
|
Strict bool `help:"Only returns if anything matched. Otherwise return Filter" negatable:"true" default:"true" group:"Selection"`
|
||||||
SelectedPrefix string `help:"Character to indicate selected items (hidden if limit is 1)" default:" ◉ " env:"GUM_FILTER_SELECTED_PREFIX"`
|
SelectedPrefix string `help:"Character to indicate selected items (hidden if limit is 1)" default:" ◉ " env:"GUM_FILTER_SELECTED_PREFIX"`
|
||||||
SelectedPrefixStyle style.Styles `embed:"" prefix:"selected-indicator." set:"defaultForeground=212" envprefix:"GUM_FILTER_SELECTED_PREFIX_"`
|
SelectedPrefixStyle style.Styles `embed:"" prefix:"selected-indicator." set:"defaultForeground=212" envprefix:"GUM_FILTER_SELECTED_PREFIX_"`
|
||||||
UnselectedPrefix string `help:"Character to indicate unselected items (hidden if limit is 1)" default:" ○ " env:"GUM_FILTER_UNSELECTED_PREFIX"`
|
UnselectedPrefix string `help:"Character to indicate unselected items (hidden if limit is 1)" default:" ○ " env:"GUM_FILTER_UNSELECTED_PREFIX"`
|
||||||
|
|
Loading…
Reference in a new issue