#59 fix gorush gocyclo error.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-04-16 17:11:31 +08:00
parent 0f09f5c851
commit 21e11b01db
1 changed files with 12 additions and 13 deletions

View File

@ -6,6 +6,16 @@ import (
"log" "log"
) )
func checkInput(token, message string) {
if len(token) == 0 {
gorush.LogError.Fatal("Missing token flag (-t)")
}
if len(message) == 0 {
gorush.LogError.Fatal("Missing message flag (-m)")
}
}
func main() { func main() {
version := flag.Bool("v", false, "gorush version") version := flag.Bool("v", false, "gorush version")
confPath := flag.String("c", "", "yaml configuration file path for gorush") confPath := flag.String("c", "", "yaml configuration file path for gorush")
@ -62,13 +72,8 @@ func main() {
// send android notification // send android notification
if *android { if *android {
if len(*token) == 0 {
gorush.LogError.Fatal("Missing token flag (-t)")
}
if len(*message) == 0 { checkInput(*token, *message)
gorush.LogError.Fatal("Missing message flag (-m)")
}
gorush.PushConf.Android.Enabled = true gorush.PushConf.Android.Enabled = true
req := gorush.PushNotification{ req := gorush.PushNotification{
@ -85,13 +90,7 @@ func main() {
// send android notification // send android notification
if *ios { if *ios {
if len(*token) == 0 { checkInput(*token, *message)
gorush.LogError.Fatal("Missing token flag (-t)")
}
if len(*message) == 0 {
gorush.LogError.Fatal("Missing message flag (-m)")
}
if *production { if *production {
gorush.PushConf.Ios.Production = true gorush.PushConf.Ios.Production = true