forked from bradfordboyle/go-distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (29 loc) · 743 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
package main
import (
"log"
"os"
"github.com/aquilax/go-distribution/histogram"
"github.com/aquilax/go-distribution/settings"
"github.com/aquilax/go-distribution/tokenize"
)
func main() {
s := settings.NewSettings(os.Args[0], os.Args[1:])
var t tokenize.Tokenizer
if s.GraphValues == "vk" {
t = tokenize.NewValueKeyTokenizer()
} else if s.GraphValues == "kv" {
t = tokenize.NewKeyValueTokenizer()
} else if s.NumOnly != "XXX" {
os.Exit(0)
} else if s.Tokenize != "" {
t = tokenize.NewRegexTokenizer(s.Tokenize, s.MatchRegexp)
} else {
t = tokenize.NewLineTokenizer(s.MatchRegexp)
}
pl, err := t.Tokenize(os.Stdin)
if err != nil {
log.Fatal(err)
}
h := histogram.NewHistogram(s)
h.WriteHist(os.Stdout, pl)
}