Skip to content

Commit

Permalink
feat(choose): select from stdin (#773)
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 authored Dec 17, 2024
1 parent 0b89ff8 commit 0f8f67f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions choose/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ func (o Options) Run() error {
verySubduedStyle = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#DDDADA", Dark: "#3C3C3C"})
)

if len(o.Options) <= 0 {
input, _ := stdin.Read(stdin.StripANSI(o.StripANSI))
input, _ := stdin.Read(stdin.StripANSI(o.StripANSI))
if len(o.Options) > 0 && len(o.Selected) == 0 {
o.Selected = strings.Split(input, o.InputDelimiter)
} else if len(o.Options) == 0 {
if input == "" {
return errors.New("no options provided, see `gum choose --help`")
}
Expand Down

0 comments on commit 0f8f67f

Please sign in to comment.