feat: add help option

This commit is contained in:
Adrien Waksberg 2019-06-27 10:58:47 +02:00 committed by Adrien Waksberg
parent 5c98cb2615
commit ab6f301467

View file

@ -11,6 +11,7 @@ import (
// Option to parse // Option to parse
var ( var (
HELP = flag.Bool("help", false, "print the help message")
HOSTNAME = flag.String("hostname", "localhost", "mysql hostname") HOSTNAME = flag.String("hostname", "localhost", "mysql hostname")
PORT = flag.Int("port", 3306, "mysql port") PORT = flag.Int("port", 3306, "mysql port")
USERNAME = flag.String("username", "", "mysql username") USERNAME = flag.String("username", "", "mysql username")
@ -24,6 +25,11 @@ var (
func init() { func init() {
flag.Parse() flag.Parse()
if *HELP {
flag.PrintDefaults()
os.Exit(3)
}
if *QUERY == "" { if *QUERY == "" {
Critical("Please set query option") Critical("Please set query option")
} }
@ -87,4 +93,3 @@ func main() {
Ok(msg) Ok(msg)
} }