Merge pull request #151 from yskopets/feature/add-prompt-hide-entered-flag

prompt: add `HideEntered` flag
This commit is contained in:
James Bowes 2020-09-28 09:34:51 -03:00 committed by GitHub
commit 0ce406edb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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()