From 901e367fe2d236bbe4afcd1d986d026dee39da87 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Fri, 8 Jul 2022 13:58:14 -0400 Subject: [PATCH] refactor: rename `gum search` to `gum filter` --- README.md | 4 ++-- examples/demo.sh | 2 +- {search => filter}/command.go | 6 +++--- search/search.go => filter/filter.go | 2 +- {search => filter}/options.go | 4 ++-- gum.go | 8 ++++---- main.go | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) rename {search => filter}/command.go (90%) rename search/search.go => filter/filter.go (99%) rename {search => filter}/options.go (86%) diff --git a/README.md b/README.md index d4abff1..4ca3650 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Prompt your users to write some multi-line text. gum write > story.text ``` -#### Search +#### Filter Allow your users to filter through a list of options by fuzzy searching. @@ -82,7 +82,7 @@ Allow your users to filter through a list of options by fuzzy searching. echo Strawberry >> flavors.text echo Banana >> flavors.text echo Cherry >> flavors.text -cat flavors.text | gum search > selection.text +cat flavors.text | gum filter > selection.text ``` #### Progress diff --git a/examples/demo.sh b/examples/demo.sh index 16897eb..3ff2334 100755 --- a/examples/demo.sh +++ b/examples/demo.sh @@ -27,7 +27,7 @@ echo "What's your favorite Gum flavor?" GUM=$(echo "Cherry Grape Lime -Orange" | gum search) +Orange" | gum filter) echo "One sec, while I finish my drink." diff --git a/search/command.go b/filter/command.go similarity index 90% rename from search/command.go rename to filter/command.go index 4fe5a2a..9d12dfa 100644 --- a/search/command.go +++ b/filter/command.go @@ -1,4 +1,4 @@ -package search +package filter import ( "fmt" @@ -13,8 +13,8 @@ import ( "github.com/charmbracelet/lipgloss" ) -// Run provides a shell script interface for the search bubble. -// https://github.com/charmbracelet/bubbles/search +// Run provides a shell script interface for filtering through options, powered +// by the textinput bubble. func (o Options) Run() { i := textinput.New() i.Focus() diff --git a/search/search.go b/filter/filter.go similarity index 99% rename from search/search.go rename to filter/filter.go index 87c258b..9834017 100644 --- a/search/search.go +++ b/filter/filter.go @@ -1,4 +1,4 @@ -package search +package filter import ( "strings" diff --git a/search/options.go b/filter/options.go similarity index 86% rename from search/options.go rename to filter/options.go index 60cbc69..8743ca4 100644 --- a/search/options.go +++ b/filter/options.go @@ -1,6 +1,6 @@ -package search +package filter -// Options is the customization options for the search. +// Options is the customization options for the filter command. type Options struct { HighlightColor string `help:"Color for highlighted matches" default:"212"` Indicator string `help:"Character for selection" default:"•"` diff --git a/gum.go b/gum.go index f26ab2f..c9792dc 100644 --- a/gum.go +++ b/gum.go @@ -1,10 +1,10 @@ package main import ( + "github.com/charmbracelet/gum/filter" "github.com/charmbracelet/gum/input" "github.com/charmbracelet/gum/join" "github.com/charmbracelet/gum/progress" - "github.com/charmbracelet/gum/search" "github.com/charmbracelet/gum/spin" "github.com/charmbracelet/gum/style" "github.com/charmbracelet/gum/write" @@ -32,7 +32,7 @@ type Gum struct { // Write write.Options `cmd:"" help:"Prompt for multi-line input."` - // Search provides a fuzzy searching text input to allow filtering a list of + // Filter provides a fuzzy searching text input to allow filtering a list of // options to select one option. // // By default it will list all the files (recursively) in the current directory @@ -41,9 +41,9 @@ type Gum struct { // // I.e. let's pick from a list of gum flavors: // - // $ cat flavors.text | gum search + // $ cat flavors.text | gum filter // - Search search.Options `cmd:"" help:"Fuzzy search options."` + Filter filter.Options `cmd:"" help:"Filter options through fuzzy search."` // Spin provides a shell script interface for the spinner bubble. // https://github.com/charmbracelet/bubbles/spinner diff --git a/main.go b/main.go index 5b61952..e4306d2 100644 --- a/main.go +++ b/main.go @@ -23,8 +23,8 @@ func main() { gum.Input.Run() case "write": gum.Write.Run() - case "search": - gum.Search.Run() + case "filter": + gum.Filter.Run() case "spin ": gum.Spin.Run() case "progress":