Skip to content

Commit

Permalink
feat: add --password option for masked input
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Jul 29, 2022
1 parent 0927958 commit 5b7d006
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions input/command.go
Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions input/options.go
Expand Up @@ -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"`
}

0 comments on commit 5b7d006

Please sign in to comment.