-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
66 lines (62 loc) · 1.6 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
package main
import (
"fmt"
"log"
"os"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
EnableBashCompletion: true,
Commands: []*cli.Command{
{
Name: "gen",
Usage: "generate models and mongodb api",
Action: func(cCtx *cli.Context) error {
fmt.Println(cCtx.Args())
fmt.Println("added task: ", cCtx.String("add"))
return nil
},
Flags: []cli.Flag{
&cli.PathFlag{
Name: "json",
Aliases: []string{"j"},
Required: true,
Usage: "path to the *.json file which contains model templates",
},
&cli.PathFlag{
Name: "dir",
Aliases: []string{"d"},
Value: "./",
Usage: "generated code will be located in this dir",
},
&cli.StringSliceFlag{
Name: "add",
Aliases: []string{"a"},
Usage: "add global field in models, format: <name>:<type>",
},
},
},
{
Name: "types",
Usage: "list available global field types mapping from reed to Go",
Action: func(cCtx *cli.Context) error {
fmt.Println("\nAvailable global field types:\t")
fmt.Println("--------------------------\t")
fmt.Println("reed\t", "\t", "Go")
fmt.Println("--------------------------\t")
fmt.Println("int\t", "--->\t", "int64")
fmt.Println("float\t", "--->\t", "float64")
fmt.Println("time\t", "--->\t", "time.Time")
fmt.Println("string\t", "--->\t", "string")
fmt.Println("bool\t", "--->\t", "bool")
fmt.Println("--------------------------\t")
return nil
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}