-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (42 loc) · 1016 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
package main
import (
"flag"
"fmt"
"os"
)
func main() {
var (
csv1Path string
csv2Path string
opDeduct bool
top1, top2 int
)
flag.BoolVar(&opDeduct, "deduct", false, "Deduct over-payments in file2 from payouts in file1")
flag.StringVar(&csv1Path, "f1", "", "first payouts CST file")
flag.StringVar(&csv2Path, "f2", "", "second payouts csv file")
flag.IntVar(&top1, "top1", 0, "limit file 1 to N records with highest FIL")
flag.IntVar(&top2, "top2", 0, "limit file 2 to N records with highest FIL")
flag.Parse()
if csv1Path == "" {
fmt.Fprintln(os.Stderr, "missing value for -f1")
os.Exit(1)
}
if csv2Path == "" {
fmt.Fprintln(os.Stderr, "missing value for -f2")
os.Exit(1)
}
var err error
if opDeduct {
if top1 != 0 {
fmt.Fprintln(os.Stderr, "-top1 is not available with -deduct")
os.Exit(1)
}
err = deduct(csv1Path, csv2Path, top2)
} else {
err = compare(csv1Path, csv2Path, top1, top2)
}
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}