-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (36 loc) · 941 Bytes
/
main.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
package main
import (
"flag"
"github.com/jessevdk/go-flags"
)
type Context int
const (
MASTERQUERY Context = iota
SINGLESERVER
)
type MainOptions struct {
Master MasterQueryOptions `command:"master"`
Server ServerQueryOptions `command:"server"`
}
var ctx Context
var userSetContext *string = flag.String("query", "master", "One of master,server. ")
func main() {
//flag.Parse()
parser := flags.NewNamedParser("sourceq", flags.Default)
parser.AddCommand("master", "Query Master Server",
"Query the Master Server for a list of Source servers. "+
"Display servers in row format.", &masterOptions)
parser.AddCommand("server", "Query Game Server", "Query a specific game server for information.", &serverSingleOptions)
extra, err := parser.Parse()
if err != nil {
return
}
switch parser.Active.Name {
case "master":
ctx = MASTERQUERY
masterctx()
case "server":
ctx = SINGLESERVER
serverctx(extra)
}
}