Skip to content

Commit

Permalink
Merge pull request #151 from yskopets/feature/add-prompt-hide-entered…
Browse files Browse the repository at this point in the history
…-flag

prompt: add `HideEntered` flag
  • Loading branch information
jbowes committed Sep 28, 2020
2 parents ff07e3d + 3614910 commit 0ce406e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 0ce406e

Please sign in to comment.