mirror of
https://github.com/charmbracelet/gum
synced 2024-06-02 05:42:18 +02:00
feat: add --password
option for masked input
This commit is contained in:
parent
0927958421
commit
5b7d006487
|
@ -31,6 +31,11 @@ func (o Options) Run() error {
|
||||||
i.PromptStyle = o.PromptStyle.ToLipgloss()
|
i.PromptStyle = o.PromptStyle.ToLipgloss()
|
||||||
i.CursorStyle = o.CursorStyle.ToLipgloss()
|
i.CursorStyle = o.CursorStyle.ToLipgloss()
|
||||||
|
|
||||||
|
if o.Password {
|
||||||
|
i.EchoMode = textinput.EchoPassword
|
||||||
|
i.EchoCharacter = '•'
|
||||||
|
}
|
||||||
|
|
||||||
p := tea.NewProgram(model{i}, tea.WithOutput(os.Stderr))
|
p := tea.NewProgram(model{i}, tea.WithOutput(os.Stderr))
|
||||||
m, err := p.StartReturningModel()
|
m, err := p.StartReturningModel()
|
||||||
fmt.Println(m.(model).textinput.Value())
|
fmt.Println(m.(model).textinput.Value())
|
||||||
|
|
|
@ -10,4 +10,5 @@ type Options struct {
|
||||||
CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" set:"name=cursor"`
|
CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" set:"name=cursor"`
|
||||||
Value string `help:"Initial value (can also be passed via stdin)" default:""`
|
Value string `help:"Initial value (can also be passed via stdin)" default:""`
|
||||||
Width int `help:"Input width" default:"40"`
|
Width int `help:"Input width" default:"40"`
|
||||||
|
Password bool `help:"Mask input characters" default:"false"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue