diff options
author | Dieter Eickstaedt <eickstaedt@deicon.de> | 2022-11-09 19:54:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 13:54:47 -0500 |
commit | b0aba2261dab58813aeeb7357e4adda196b394b7 (patch) | |
tree | 46e69a1959ff7667f3ddad73b2990d714576812b | |
parent | e38cfdaa1023b4bcc7052623e9432cb5f502fda2 (diff) |
feature(choose): Adding option to use non-matching filter as result (#233)
-rw-r--r-- | filter/command.go | 4 | ||||
-rw-r--r-- | filter/options.go | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/filter/command.go b/filter/command.go index 3596cc2..5cb3cfd 100644 --- a/filter/command.go +++ b/filter/command.go @@ -87,7 +87,6 @@ func (o Options) Run() error { return fmt.Errorf("unable to run filter: %w", err) } m := tm.(model) - if m.aborted { return exit.ErrAborted } @@ -103,6 +102,9 @@ func (o Options) Run() error { 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 } diff --git a/filter/options.go b/filter/options.go index 3737e8f..07e3551 100644 --- a/filter/options.go +++ b/filter/options.go @@ -8,6 +8,7 @@ type Options struct { 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"` 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"` 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"` |