-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (34 loc) · 882 Bytes
/
main.go
File metadata and controls
41 lines (34 loc) · 882 Bytes
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
package main
import (
"flag"
"fmt"
"os"
"github.com/HawAPI/api-data/internal/converter"
)
func main() {
var singleFile bool
var inputDir string
var outputDir string
flag.BoolVar(&singleFile, "single", true, "define if output will be in a single or multiple files")
flag.StringVar(&inputDir, "in", "database/v1/data", "input directory")
flag.StringVar(&outputDir, "out", "database/v1/data/sql", "output directory")
flag.Parse()
flag.Usage = cmdUsage
// Create the output directory if it does not exist
if _, err := os.Stat(outputDir); os.IsNotExist(err) {
err = os.Mkdir(outputDir, 0755)
if err != nil {
panic(err)
}
}
conv := converter.New(inputDir, outputDir, singleFile)
err := conv.Start()
if err != nil {
panic(err)
}
}
func cmdUsage() {
w := flag.CommandLine.Output()
fmt.Fprintf(w, "Usage of %s: \n", os.Args[0])
flag.PrintDefaults()
}