-
Notifications
You must be signed in to change notification settings - Fork 0
/
flag-checker.go
50 lines (35 loc) · 1002 Bytes
/
flag-checker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"flag"
"fmt"
)
func CheckFlags() (bool, string, string, string) {
var goodFlags bool = true
var helpFlag bool
var seasonFlag string
var eventCodeFlag string
var apiKeyFlag string
flag.BoolVar(&helpFlag, "h", false, "Show this help message")
flag.StringVar(&seasonFlag, "s", "", "The season of the event")
flag.StringVar(&eventCodeFlag, "e", "", "The event code of the event")
flag.StringVar(&apiKeyFlag, "k", "", "The API key to use")
flag.Parse()
if helpFlag {
fmt.Println("flags:")
flag.PrintDefaults()
goodFlags = false
}
if !helpFlag && seasonFlag == "" {
fmt.Println("Season flag is required")
goodFlags = false
}
if !helpFlag && eventCodeFlag == "" {
fmt.Println("Event code flag is required")
goodFlags = false
}
if !helpFlag && apiKeyFlag == "" {
fmt.Println("API key is required\n(Should be in the form of \"username:authorizationKey\")")
goodFlags = false
}
return goodFlags, seasonFlag, eventCodeFlag, apiKeyFlag
}