Last active
August 29, 2015 13:58
-
-
Save lessless/9930372 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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