mirror of
https://github.com/manifoldco/promptui.git
synced 2026-03-14 22:35:53 +01:00
Merge pull request #151 from yskopets/feature/add-prompt-hide-entered-flag
prompt: add `HideEntered` flag
This commit is contained in:
commit
0ce406edb7
1 changed files with 11 additions and 3 deletions
14
prompt.go
14
prompt.go
|
|
@ -33,6 +33,9 @@ type Prompt struct {
|
|||
// allows hiding private information like passwords.
|
||||
Mask rune
|
||||
|
||||
// HideEntered sets whether to hide the text after the user has pressed enter.
|
||||
HideEntered bool
|
||||
|
||||
// Templates can be used to customize the prompt output. If nil is passed, the
|
||||
// default templates are used. See the PromptTemplates docs for more info.
|
||||
Templates *PromptTemplates
|
||||
|
|
@ -234,9 +237,14 @@ func (p *Prompt) Run() (string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
sb.Reset()
|
||||
sb.Write(prompt)
|
||||
sb.Flush()
|
||||
if p.HideEntered {
|
||||
clearScreen(sb)
|
||||
} else {
|
||||
sb.Reset()
|
||||
sb.Write(prompt)
|
||||
sb.Flush()
|
||||
}
|
||||
|
||||
rl.Write([]byte(showCursor))
|
||||
rl.Close()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue