-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (41 loc) · 1010 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
package main
import (
"flag"
"fmt"
"os"
"strings"
)
var (
outputFormat string
initialAddresses string
password string
)
var outputs = map[string]Outputter{
"debug": newDebugOutputter(os.Stdout),
"graphviz": newGraphvizOutputter(os.Stdout),
}
func init() {
flag.StringVar(&outputFormat, "output", "graphviz", "the output format")
flag.StringVar(&initialAddresses, "addr", "", "the initial addresses, csv style")
flag.StringVar(&password, "pass", "", "the authentication password")
}
func main() {
flag.Parse()
addresses := strings.Split(initialAddresses, ",")
if len(addresses) == 0 {
fmt.Println("Flag addr not set.")
flag.PrintDefaults()
os.Exit(1)
}
discoverer := NewDiscoverer(addresses, password)
if err := discoverer.BuildGraph(); err != nil {
fmt.Printf("During building of graph %v", err)
os.Exit(1)
}
if outputter, ok := outputs[outputFormat]; ok {
outputter.Print(discoverer.Result())
} else {
fmt.Println("Unknown output")
os.Exit(1)
}
}