mirror of
https://github.com/charmbracelet/gum
synced 2024-06-01 13:22:26 +02:00
refactor: rename gum search
to gum filter
This commit is contained in:
parent
432d6dd032
commit
901e367fe2
|
@ -74,7 +74,7 @@ Prompt your users to write some multi-line text.
|
||||||
gum write > story.text
|
gum write > story.text
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Search
|
#### Filter
|
||||||
|
|
||||||
Allow your users to filter through a list of options by fuzzy searching.
|
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 Strawberry >> flavors.text
|
||||||
echo Banana >> flavors.text
|
echo Banana >> flavors.text
|
||||||
echo Cherry >> flavors.text
|
echo Cherry >> flavors.text
|
||||||
cat flavors.text | gum search > selection.text
|
cat flavors.text | gum filter > selection.text
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Progress
|
#### Progress
|
||||||
|
|
|
@ -27,7 +27,7 @@ echo "What's your favorite Gum flavor?"
|
||||||
GUM=$(echo "Cherry
|
GUM=$(echo "Cherry
|
||||||
Grape
|
Grape
|
||||||
Lime
|
Lime
|
||||||
Orange" | gum search)
|
Orange" | gum filter)
|
||||||
|
|
||||||
echo "One sec, while I finish my drink."
|
echo "One sec, while I finish my drink."
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package search
|
package filter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -13,8 +13,8 @@ import (
|
||||||
"github.com/charmbracelet/lipgloss"
|
"github.com/charmbracelet/lipgloss"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Run provides a shell script interface for the search bubble.
|
// Run provides a shell script interface for filtering through options, powered
|
||||||
// https://github.com/charmbracelet/bubbles/search
|
// by the textinput bubble.
|
||||||
func (o Options) Run() {
|
func (o Options) Run() {
|
||||||
i := textinput.New()
|
i := textinput.New()
|
||||||
i.Focus()
|
i.Focus()
|
|
@ -1,4 +1,4 @@
|
||||||
package search
|
package filter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
|
@ -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 {
|
type Options struct {
|
||||||
HighlightColor string `help:"Color for highlighted matches" default:"212"`
|
HighlightColor string `help:"Color for highlighted matches" default:"212"`
|
||||||
Indicator string `help:"Character for selection" default:"•"`
|
Indicator string `help:"Character for selection" default:"•"`
|
8
gum.go
8
gum.go
|
@ -1,10 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/charmbracelet/gum/filter"
|
||||||
"github.com/charmbracelet/gum/input"
|
"github.com/charmbracelet/gum/input"
|
||||||
"github.com/charmbracelet/gum/join"
|
"github.com/charmbracelet/gum/join"
|
||||||
"github.com/charmbracelet/gum/progress"
|
"github.com/charmbracelet/gum/progress"
|
||||||
"github.com/charmbracelet/gum/search"
|
|
||||||
"github.com/charmbracelet/gum/spin"
|
"github.com/charmbracelet/gum/spin"
|
||||||
"github.com/charmbracelet/gum/style"
|
"github.com/charmbracelet/gum/style"
|
||||||
"github.com/charmbracelet/gum/write"
|
"github.com/charmbracelet/gum/write"
|
||||||
|
@ -32,7 +32,7 @@ type Gum struct {
|
||||||
//
|
//
|
||||||
Write write.Options `cmd:"" help:"Prompt for multi-line input."`
|
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.
|
// options to select one option.
|
||||||
//
|
//
|
||||||
// By default it will list all the files (recursively) in the current directory
|
// 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:
|
// 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.
|
// Spin provides a shell script interface for the spinner bubble.
|
||||||
// https://github.com/charmbracelet/bubbles/spinner
|
// https://github.com/charmbracelet/bubbles/spinner
|
||||||
|
|
4
main.go
4
main.go
|
@ -23,8 +23,8 @@ func main() {
|
||||||
gum.Input.Run()
|
gum.Input.Run()
|
||||||
case "write":
|
case "write":
|
||||||
gum.Write.Run()
|
gum.Write.Run()
|
||||||
case "search":
|
case "filter":
|
||||||
gum.Search.Run()
|
gum.Filter.Run()
|
||||||
case "spin <command>":
|
case "spin <command>":
|
||||||
gum.Spin.Run()
|
gum.Spin.Run()
|
||||||
case "progress":
|
case "progress":
|
||||||
|
|
Loading…
Reference in a new issue