2022-07-06 18:06:08 +02:00
|
|
|
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()
|
|
|
|
|
2022-07-11 22:53:11 +02:00
|
|
|
i.SetValue(o.Value)
|
2022-07-06 18:06:08 +02:00
|
|
|
i.Prompt = o.Prompt
|
|
|
|
i.Placeholder = o.Placeholder
|
|
|
|
i.Width = o.Width
|
2022-07-12 22:05:40 +02:00
|
|
|
i.PromptStyle = o.PromptStyle.ToLipgloss()
|
|
|
|
i.CursorStyle = o.CursorStyle.ToLipgloss()
|
2022-07-06 18:06:08 +02:00
|
|
|
|
|
|
|
p := tea.NewProgram(model{i}, tea.WithOutput(os.Stderr))
|
|
|
|
m, _ := p.StartReturningModel()
|
|
|
|
fmt.Println(m.(model).textinput.Value())
|
|
|
|
}
|