Skip to content

Instantly share code, notes, and snippets.

@larzconwell
Last active August 29, 2015 14:09
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 larzconwell/e6baa64c11b6a0e77d5a to your computer and use it in GitHub Desktop.
Save larzconwell/e6baa64c11b6a0e77d5a to your computer and use it in GitHub Desktop.
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