From b0aba2261dab58813aeeb7357e4adda196b394b7 Mon Sep 17 00:00:00 2001 From: Dieter Eickstaedt Date: Wed, 9 Nov 2022 19:54:47 +0100 Subject: [PATCH 1/3] feature(choose): Adding option to use non-matching filter as result (#233) --- filter/command.go | 4 +++- filter/options.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) 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"` From 614f0e80288fd68a69e841c690cdd5fa35277116 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Wed, 9 Nov 2022 23:13:21 -0500 Subject: [PATCH 2/3] feat(style): allow passing input over stdin --- style/command.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/style/command.go b/style/command.go index a8045ac..5412ec7 100644 --- a/style/command.go +++ b/style/command.go @@ -6,16 +6,27 @@ package style import ( + "errors" "fmt" "strings" "github.com/alecthomas/kong" + "github.com/charmbracelet/gum/internal/stdin" ) // Run provides a shell script interface for the Lip Gloss styling. // https://github.com/charmbracelet/lipgloss func (o Options) Run() error { - text := strings.Join(o.Text, "\n") + var text string + if len(o.Text) > 0 { + text = strings.Join(o.Text, "\n") + } else { + text, _ = stdin.Read() + if text == "" { + return errors.New("no input provided, see `gum style --help`") + } + text = strings.TrimSuffix(text, "\n") + } fmt.Println(o.Style.ToLipgloss().Render(text)) return nil } From eb3c5c1037a5756b25771e078eaf8ccfd91a00e8 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 18 Nov 2022 02:11:34 +0100 Subject: [PATCH 3/3] chore: disable dependabot timer --- .github/dependabot.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d0b49cd..9fc3b07 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,7 +4,6 @@ updates: directory: "/" schedule: interval: "daily" - time: "08:00" labels: - "dependencies" commit-message: @@ -14,7 +13,6 @@ updates: directory: "/" schedule: interval: "daily" - time: "08:00" labels: - "dependencies" commit-message: