-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
59 lines (51 loc) · 1.31 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
package main
import (
"flag"
"fmt"
"github.com/benbusby/y2k/src/interpreter"
"github.com/benbusby/y2k/src/utils"
)
func main() {
var timestamp string
digits := flag.Int(
"d",
1,
"Set # of digits to parse at a time")
debug := flag.Bool(
"debug",
false,
"Enable to view interpreter steps in console")
export := flag.Bool(
"export",
false,
"Export a Y2K raw file to a set of timestamp-only files")
outdir := flag.String(
"outdir",
"./y2k-out",
"Set the output directory for timestamp-only files when exporting a raw Y2K file.\n"+
"This directory will be created if it does not exist.")
flag.Parse()
y2k := &interpreter.Y2K{Digits: *digits, Debug: *debug}
for _, arg := range flag.Args() {
// Assume first argument is the directory or file to use for parsing
if len(timestamp) == 0 {
if *export {
// If we're exporting, assume we're only reading raw Y2K file
// contents, and export to a set of empty files.
timestamp = utils.ReadY2KRawFile(arg)
utils.ExportRawToTimestampFiles(timestamp, *outdir)
return
} else {
timestamp = utils.GetTimestamps(arg, *digits)
}
continue
}
y2k.FromCLIArg(arg)
}
if len(timestamp) == 0 {
fmt.Println("Missing input dir!\n\nUsage: y2k <directory> [args]")
flag.PrintDefaults()
return
}
y2k.Parse(timestamp)
}