feat: add --password option for masked input

This commit is contained in:
Maas Lalani 2022-07-29 11:19:40 -04:00
parent 0927958421
commit 5b7d006487
2 changed files with 6 additions and 0 deletions

View file

@ -31,6 +31,11 @@ func (o Options) Run() error {
i.PromptStyle = o.PromptStyle.ToLipgloss()
i.CursorStyle = o.CursorStyle.ToLipgloss()
if o.Password {
i.EchoMode = textinput.EchoPassword
i.EchoCharacter = '•'
}
p := tea.NewProgram(model{i}, tea.WithOutput(os.Stderr))
m, err := p.StartReturningModel()
fmt.Println(m.(model).textinput.Value())

View file

@ -10,4 +10,5 @@ type Options struct {
CursorStyle style.Styles `embed:"" prefix:"cursor." set:"defaultForeground=212" set:"name=cursor"`
Value string `help:"Initial value (can also be passed via stdin)" default:""`
Width int `help:"Input width" default:"40"`
Password bool `help:"Mask input characters" default:"false"`
}