mirror of
https://github.com/charmbracelet/gum.git
synced 2024-09-11 06:16:03 +03:00
feat: allow initial values of input and write to be set via stdin
This commit is contained in:
parent
02e925ea57
commit
bf8d9964df
@ -8,6 +8,6 @@ type Options struct {
|
||||
Prompt string `help:"Prompt to display" default:"> "`
|
||||
PromptStyle style.Styles `embed:"" prefix:"prompt." set:"name=prompt"`
|
||||
CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" set:"name=cursor"`
|
||||
Value string `help:"Initial value" default:""`
|
||||
Value string `help:"Initial value (can also be passed via stdin)" default:""`
|
||||
Width int `help:"Input width" default:"20"`
|
||||
}
|
||||
|
8
main.go
8
main.go
@ -23,8 +23,16 @@ func main() {
|
||||
)
|
||||
switch ctx.Command() {
|
||||
case "input":
|
||||
v, _ := stdin.Read()
|
||||
if v != "" {
|
||||
gum.Input.Value = v
|
||||
}
|
||||
gum.Input.Run()
|
||||
case "write":
|
||||
v, _ := stdin.Read()
|
||||
if v != "" {
|
||||
gum.Write.Value = v
|
||||
}
|
||||
gum.Write.Run()
|
||||
case "filter":
|
||||
gum.Filter.Run()
|
||||
|
@ -10,7 +10,7 @@ type Options struct {
|
||||
Prompt string `help:"Prompt to display" default:"┃ "`
|
||||
ShowCursorLine bool `help:"Show cursor line" default:"false"`
|
||||
ShowLineNumbers bool `help:"Show line numbers" default:"false"`
|
||||
Value string `help:"Initial value" default:""`
|
||||
Value string `help:"Initial value (can be passed via stdin)" default:""`
|
||||
|
||||
BaseStyle style.Styles `embed:"" prefix:"base." set:"name=base"`
|
||||
CursorLineNumberStyle style.Styles `embed:"" prefix:"cursor-line-number." set:"defaultForeground=7" set:"name=cursor line number"`
|
||||
|
Loading…
Reference in New Issue
Block a user