add command usage.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
4239980dc6
commit
c39c8021d9
40
gorush.go
40
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 <port> Use port for clients (default: 8088)
|
||||
-c, --config <file> Configuration file
|
||||
-m, --message <message> Notification message
|
||||
-t, --token <token> Notification token
|
||||
iOS Options:
|
||||
-i, --pem <file> certificate key file path
|
||||
-P, --password <password> certificate key password
|
||||
--topic <topic> iOS topic
|
||||
--ios enabled iOS (default: false)
|
||||
--production iOS production mode (default: false)
|
||||
Android Options:
|
||||
-k, --key <api_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()
|
||||
|
|
Loading…
Reference in New Issue