Skip to content

Commit

Permalink
fix: clarify filter --sort flag (#738)
Browse files Browse the repository at this point in the history
* fix: clarify filter --sort flag

Signed-off-by: Carlos Alexandro Becker <[email protected]>

* fix: if sort, sort options alphabetically first

* Revert "fix: if sort, sort options alphabetically first"

This reverts commit 86e8fc0.

* fix: filter

* Update filter/options.go

Co-authored-by: Christian Rocha <[email protected]>

---------

Signed-off-by: Carlos Alexandro Becker <[email protected]>
Co-authored-by: Christian Rocha <[email protected]>
  • Loading branch information
caarlos0 and meowgorithm authored Dec 4, 2024
1 parent 63a3e8c commit c422e76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion filter/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (o Options) Run() error {
fuzzy: o.Fuzzy,
timeout: o.Timeout,
hasTimeout: o.Timeout > 0,
sort: o.Sort,
sort: o.Sort && o.FuzzySort,
}, options...)

tm, err := p.Run()
Expand Down
7 changes: 5 additions & 2 deletions filter/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ type Options struct {
Height int `help:"Input height" default:"0" env:"GUM_FILTER_HEIGHT"`
Value string `help:"Initial filter value" default:"" env:"GUM_FILTER_VALUE"`
Reverse bool `help:"Display from the bottom of the screen" env:"GUM_FILTER_REVERSE"`
Fuzzy bool `help:"Enable fuzzy matching" default:"true" env:"GUM_FILTER_FUZZY" negatable:""`
Sort bool `help:"Sort the results" default:"true" env:"GUM_FILTER_SORT" negatable:""`
Fuzzy bool `help:"Enable fuzzy matching; otherwise match from start of word" default:"true" env:"GUM_FILTER_FUZZY" negatable:""`
FuzzySort bool `help:"Sort fuzzy results by their scores" default:"true" env:"GUM_FILTER_FUZZY_SORT" negatable:""`
Timeout time.Duration `help:"Timeout until filter command aborts" default:"0s" env:"GUM_FILTER_TIMEOUT"`

// Deprecated: use [FuzzySort]. This will be removed at some point.
Sort bool `help:"Sort fuzzy results by their scores" default:"true" env:"GUM_FILTER_FUZZY_SORT" negatable:"" hidden:""`
}

0 comments on commit c422e76

Please sign in to comment.