-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.go
48 lines (41 loc) · 856 Bytes
/
action.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
package evalid
import (
"github.com/urfave/cli"
)
var Usage = "generate enum valid function"
var Description = "make a isXXXXValid function"
var Flags = []cli.Flag{
//valid --const target --type string --name isTargetValid --output xxxx.go
cli.StringFlag{
Name: "const,c",
Usage: "the const to validate",
},
cli.StringFlag{
Name: "type,t",
Usage: "the variable type",
},
cli.StringFlag{
Name: "name,n",
Usage: "the function `NAME`",
},
cli.StringFlag{
Name: "output,o",
Usage: "output to `FILE`",
},
}
func Action(c *cli.Context) error {
ct := c.String("const")
t := c.String("type")
name := c.String("name")
output := c.String("output")
input := c.Args().Get(0)
config := &Config{
Const: ct,
Type: t,
Name: name,
Output: output,
Input: input,
}
g := NewGenerator()
return g.Generate(config)
}