Last active
August 29, 2015 14:09
-
-
Save larzconwell/e6baa64c11b6a0e77d5a 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
package main | |
import ( | |
"flag" | |
"github.com/Bowery/prompt" | |
"os" | |
) | |
var ( | |
prefix string | |
silent bool | |
) | |
func init() { | |
flag.StringVar(&prefix, "p", "", "Display a prompt prefix.") | |
flag.BoolVar(&silent, "s", false, "Silent mode, characters are not printed.") | |
} | |
func main() { | |
flag.Parse() | |
var ( | |
out string | |
err error | |
) | |
if silent { | |
out, err = prompt.Password(prefix) | |
} else { | |
out, err = prompt.Basic(prefix, false) | |
} | |
if err != nil { | |
os.Stderr.Write([]byte(err.Error())) | |
os.Exit(1) | |
} | |
os.Stdout.Write([]byte(out + "\n")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment