gum/input/command.go
Maas Lalani 2f07eacf50
feat: Add gum input command
Input provides a shell script interface for the text input bubble. It
can be used to prompt the user for some input. The text the user entered
will be sent to `stdout`.

```
gum input --placeholder "What's your Bubble Gum flavor?" > answer.text
````
2022-07-07 13:28:52 -04:00

25 lines
517 B
Go

package input
import (
"fmt"
"os"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
)
// Run provides a shell script interface for the text input bubble.
// https://github.com/charmbracelet/bubbles/textinput
func (o Options) Run() {
i := textinput.New()
i.Focus()
i.Prompt = o.Prompt
i.Placeholder = o.Placeholder
i.Width = o.Width
p := tea.NewProgram(model{i}, tea.WithOutput(os.Stderr))
m, _ := p.StartReturningModel()
fmt.Println(m.(model).textinput.Value())
}