feat(choose): select from stdin (#773)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2024-12-17 14:43:24 -03:00 committed by GitHub
commit 0f8f67f96e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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`")
}