Skip to content

Commit

Permalink
fix: use o.Options
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Nov 28, 2023
1 parent 67ff063 commit 58d4b80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 5 additions & 9 deletions choose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ func (o Options) Run() error {
}
}

print(s.String())
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Print(s.String())
} else {
fmt.Print(ansi.Strip(s.String()))
}

return nil
}
Expand All @@ -157,14 +161,6 @@ func (o Options) BeforeReset(ctx *kong.Context) error {
return nil
}

func print(s string) {
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Print(s)
} else {
fmt.Print(ansi.Strip(s))
}
}

// Check if an array contains a value.
func arrayContains(strArray []string, value string) bool {
for _, str := range strArray {
Expand Down
6 changes: 3 additions & 3 deletions filter/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func (o Options) Run() error {
return errors.New("no options provided, see `gum filter --help`")
}

if o.SelectIfOne && len(choices) == 1 {
if o.SelectIfOne && len(o.Options) == 1 {
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Print(choices[0])
fmt.Print(o.Options[0])
} else {
fmt.Print(ansi.Strip(choices[0]))
fmt.Print(ansi.Strip(o.Options[0]))
}
return nil
}
Expand Down

0 comments on commit 58d4b80

Please sign in to comment.