-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (53 loc) · 1.09 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
package main
import (
"errors"
"flag"
"fmt"
"os"
"github.com/lgynico/alpaca/mate"
)
var (
config_dir string
json_out string
go_out string
w = flag.CommandLine.Output()
)
func init() {
flag.StringVar(&config_dir, "dir", "", "path to excel config files")
flag.StringVar(&json_out, "json_out", "", "path to output json files")
flag.StringVar(&go_out, "go_out", "", "path to output golang files")
flag.Usage = usage
}
func main() {
flag.Parse()
if err := checkFlags(); err != nil {
fmt.Fprintln(w, err.Error())
flag.Usage()
os.Exit(1)
}
mates, err := mate.Parse(config_dir)
if err != nil {
panic(err)
}
for _, exec := range executors {
if err = exec(mates); err != nil {
panic(err)
}
}
}
func usage() {
fmt.Fprintln(w, "Usage:")
fmt.Fprintln(w, " alpaca [flags]")
fmt.Fprintln(w, "")
fmt.Fprintln(w, "Flags:")
flag.CommandLine.PrintDefaults()
}
func checkFlags() error {
if len(config_dir) == 0 {
return errors.New("flag -dir is require")
}
if len(json_out) == 0 && len(go_out) == 0 {
return errors.New("specify at least one *_out flag")
}
return nil
}