-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
58 lines (48 loc) · 917 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
50
51
52
53
54
55
56
57
58
package main
import (
"flag"
"fmt"
"os"
"wlpv/cli"
"wlpv/inet"
"wlpv/offline"
"wlpv/tui"
"wlpv/xmlparser"
)
func main() {
opts, err := cli.ParseArguments()
if err != nil {
os.Exit(1)
}
if opts.Help {
flag.Usage()
os.Exit(0)
}
if opts.Version {
fmt.Println("0.0.1")
os.Exit(0)
}
protocols := make(map[string][]xmlparser.Protocol)
protocols["User"] = opts.Additions
if opts.Offline {
protocolsFromSystem, err := offline.GetProtocolContents()
if err != nil {
os.Exit(1)
}
for namespace, protocolGroup := range protocolsFromSystem {
protocols[namespace] = protocolGroup
}
} else {
protocolsFromNet, err := inet.GetProtocolContents()
if err != nil {
os.Exit(1)
}
for namespace, protocolGroup := range protocolsFromNet {
protocols[namespace] = protocolGroup
}
}
if err := tui.Run(opts.Protocol, protocols); err != nil {
os.Exit(1)
}
os.Exit(0)
}