Skip to content

Instantly share code, notes, and snippets.

@lessless
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lessless/9930372 to your computer and use it in GitHub Desktop.
Save lessless/9930372 to your computer and use it in GitHub Desktop.
func LoginCommand(c *cli.Context) {
a, _ := getInput("Plain input: ")
fmt.Println(a)
a, _ = getInput("Hidden input: ", true)
fmt.Println(a)
}
func getInput(a ...interface{}) (text string, err error) {
var isHidden bool
if len(a) == 2 {
isHidden, _ = a[1].(bool)
}
if isHidden {
text, err = gopass.GetPass(a[0].(string))
} else {
fmt.Print(a[0])
_, err = fmt.Scanln(&text)
}
return text, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment