-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
72 lines (56 loc) · 1.27 KB
/
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"flag"
"fmt"
"os"
arc "github.com/RustedPipe/arct"
)
// Values of these vars are passed during the build (Makefile).
var (
Version = ""
Commit = ""
Date = ""
)
func main() {
var filein, fileout string
var ver bool
flag.StringVar(&filein, "in", "", "ArcTool log file to process")
flag.StringVar(&fileout, "out", "", "Output CSV file")
flag.BoolVar(&ver, "version", false, "Show version")
flag.Parse()
flag.Usage = func() {
fmt.Println(`
Arct - A simple ArcTool log processor for generating CSV data files.
Flags:
-version "Show arct version and exit"
-in "A path to the log file generated by the ArcTool."
-out "A path to the csv file you want to generate."
Usage:
// To generate csv file with data from the log file
arct -in=LoaderLogs_19-02-2020.txt -out=data.csv`)
}
if ver {
showVersion()
os.Exit(0)
}
verifyFlags(filein, fileout)
if err := run(filein, fileout); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func run(fin, fout string) error {
if err := arc.GenerateReport(fin, fout); err != nil {
return err
}
return nil
}
func verifyFlags(in, out string) {
if in == "" || out == "" {
flag.Usage()
os.Exit(1)
}
}
func showVersion() {
fmt.Printf("\nVersion: %s\nBuild: %s\nDate: %s\n", Version, Commit, Date)
}