feat(input): allow placeholder style customization

This commit is contained in:
Maas Lalani 2024-01-13 15:26:27 -05:00
parent cd115c44e9
commit 7e5b494ae4
2 changed files with 14 additions and 12 deletions

View file

@ -27,6 +27,7 @@ func (o Options) Run() error {
i.Placeholder = o.Placeholder i.Placeholder = o.Placeholder
i.Width = o.Width i.Width = o.Width
i.PromptStyle = o.PromptStyle.ToLipgloss() i.PromptStyle = o.PromptStyle.ToLipgloss()
i.PlaceholderStyle = o.PlaceholderStyle.ToLipgloss()
i.Cursor.Style = o.CursorStyle.ToLipgloss() i.Cursor.Style = o.CursorStyle.ToLipgloss()
i.Cursor.SetMode(cursor.Modes[o.CursorMode]) i.Cursor.SetMode(cursor.Modes[o.CursorMode])
i.CharLimit = o.CharLimit i.CharLimit = o.CharLimit

View file

@ -11,6 +11,7 @@ type Options struct {
Placeholder string `help:"Placeholder value" default:"Type something..." env:"GUM_INPUT_PLACEHOLDER"` Placeholder string `help:"Placeholder value" default:"Type something..." env:"GUM_INPUT_PLACEHOLDER"`
Prompt string `help:"Prompt to display" default:"> " env:"GUM_INPUT_PROMPT"` Prompt string `help:"Prompt to display" default:"> " env:"GUM_INPUT_PROMPT"`
PromptStyle style.Styles `embed:"" prefix:"prompt." envprefix:"GUM_INPUT_PROMPT_"` PromptStyle style.Styles `embed:"" prefix:"prompt." envprefix:"GUM_INPUT_PROMPT_"`
PlaceholderStyle style.Styles `embed:"" prefix:"placeholder." envprefix:"GUM_INPUT_PLACEHOLDER_"`
CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_INPUT_CURSOR_"` CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" envprefix:"GUM_INPUT_CURSOR_"`
CursorMode string `prefix:"cursor." name:"mode" help:"Cursor mode" default:"blink" enum:"blink,hide,static" env:"GUM_INPUT_CURSOR_MODE"` CursorMode string `prefix:"cursor." name:"mode" help:"Cursor mode" default:"blink" enum:"blink,hide,static" env:"GUM_INPUT_CURSOR_MODE"`
Value string `help:"Initial value (can also be passed via stdin)" default:""` Value string `help:"Initial value (can also be passed via stdin)" default:""`