mirror of
https://github.com/charmbracelet/gum
synced 2024-06-05 07:12:19 +02:00
2f07eacf50
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 ````
25 lines
517 B
Go
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())
|
|
}
|