-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (25 loc) · 922 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
package main
import (
"flag"
"github.com/cheggaaa/pb/v3"
"github.com/scopserv-southafrica/callcoster/csv"
"github.com/scopserv-southafrica/callcoster/error"
"github.com/scopserv-southafrica/callcoster/filter"
"github.com/scopserv-southafrica/callcoster/report"
)
var bar *pb.ProgressBar
func main() {
reportFilename := flag.String("report", "", "The file to calculate call costs on")
rates := flag.String("rates", "", "The file from which costs will be used")
flag.Parse()
reportLines, err := csv.Read(*reportFilename)
error.Check(err)
csv.AddColumns(reportLines, "Cost", "Code")
reportHeaders, reportLines := reportLines[0], reportLines[1:]
rateLines, err := csv.Read(*rates)
error.Check(err)
validnums, _ := report.ValidateNumbers(reportLines)
filter.ValidCalls(validnums, rateLines)
reportLines = append([][]string{reportHeaders}, validnums...)
csv.Write(reportLines, *reportFilename)
}