diff --git a/gorush.go b/gorush.go index 90163a7..1aa0425 100644 --- a/gorush.go +++ b/gorush.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "github.com/appleboy/gorush/config" "github.com/appleboy/gorush/gorush" "log" @@ -20,6 +21,34 @@ func checkInput(token, message string) { var Version = "No Version Provided" +var usageStr = ` +Usage: gorush [options] + +Server Options: + -p, --port Use port for clients (default: 8088) + -c, --config Configuration file + -m, --message Notification message + -t, --token Notification token +iOS Options: + -i, --pem certificate key file path + -P, --password certificate key password + --topic iOS topic + --ios enabled iOS (default: false) + --production iOS production mode (default: false) +Android Options: + -k, --key Android API Key + --android enabled android (default: false) +Common Options: + -h, --help Show this message + -v, --version Show version +` + +// usage will print out the flag options for the server. +func usage() { + fmt.Printf("%s\n", usageStr) + os.Exit(0) +} + func main() { opts := config.ConfYaml{} @@ -34,20 +63,31 @@ func main() { flag.StringVar(&configFile, "c", "", "Configuration file.") flag.StringVar(&configFile, "config", "", "Configuration file.") flag.StringVar(&opts.Ios.PemPath, "i", "", "iOS certificate key file path") + flag.StringVar(&opts.Ios.PemPath, "pem", "", "iOS certificate key file path") + flag.StringVar(&opts.Ios.Password, "P", "", "iOS certificate password for gorush") flag.StringVar(&opts.Ios.Password, "password", "", "iOS certificate password for gorush") flag.StringVar(&opts.Android.APIKey, "k", "", "Android api key configuration for gorush") + flag.StringVar(&opts.Android.APIKey, "key", "", "Android api key configuration for gorush") flag.StringVar(&opts.Core.Port, "p", "", "port number for gorush") + flag.StringVar(&opts.Core.Port, "port", "", "port number for gorush") flag.StringVar(&token, "t", "", "token string") + flag.StringVar(&token, "token", "", "token string") flag.StringVar(&message, "m", "", "notification message") + flag.StringVar(&message, "message", "", "notification message") flag.BoolVar(&opts.Android.Enabled, "android", false, "send android notification") flag.BoolVar(&opts.Ios.Enabled, "ios", false, "send ios notification") flag.BoolVar(&opts.Ios.Production, "production", false, "production mode in iOS") flag.StringVar(&topic, "topic", "", "apns topic in iOS") + flag.Usage = usage flag.Parse() gorush.SetVersion(Version) + if len(os.Args) < 2 { + usage() + } + // Show version and exit if showVersion { gorush.PrintGoRushVersion()