mirror of
https://github.com/charmbracelet/gum
synced 2024-05-17 13:46:42 +02:00
feat: Allow setting initial value for input
and write
This commit is contained in:
parent
46ddc28ae5
commit
593cf711be
|
@ -15,6 +15,7 @@ func (o Options) Run() {
|
|||
i := textinput.New()
|
||||
i.Focus()
|
||||
|
||||
i.SetValue(o.Value)
|
||||
i.Prompt = o.Prompt
|
||||
i.Placeholder = o.Placeholder
|
||||
i.Width = o.Width
|
||||
|
|
|
@ -6,5 +6,6 @@ type Options struct {
|
|||
Placeholder string `help:"Placeholder value" default:"Type something..."`
|
||||
Prompt string `help:"Prompt to display" default:"> "`
|
||||
PromptColor string `help:"Color of prompt" default:"7"`
|
||||
Value string `help:"Initial value" default:""`
|
||||
Width int `help:"Input width" default:"20"`
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ func (o Options) Run() {
|
|||
|
||||
a.SetWidth(o.Width)
|
||||
a.SetHeight(o.Height)
|
||||
a.SetValue(o.Value)
|
||||
|
||||
p := tea.NewProgram(model{a}, tea.WithOutput(os.Stderr))
|
||||
m, _ := p.StartReturningModel()
|
||||
|
|
|
@ -9,5 +9,6 @@ type Options struct {
|
|||
PromptColor string `help:"Prompt color" default:"238"`
|
||||
ShowCursorLine bool `help:"Show cursor line" default:"false"`
|
||||
ShowLineNumbers bool `help:"Show line numbers" default:"false"`
|
||||
Value string `help:"Initial value" default:""`
|
||||
Width int `help:"Text area width" default:"50"`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue