mirror of
https://github.com/charmbracelet/gum
synced 2026-03-14 13:45:45 +01:00
feat(choose): select from stdin (#773)
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
0b89ff82d4
commit
0f8f67f96e
1 changed files with 4 additions and 2 deletions
|
|
@ -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`")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue