-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
141 lines (137 loc) · 3.44 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package main
import (
"os"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "lux",
Usage: "A simple web framework",
Commands: []*cli.Command{
{
Name: "init",
Aliases: []string{"i"},
Usage: "Initialize a new project",
UsageText: "lux init [repository]\n\n" + "Example:\n" + " lux init myproject",
Action: initProject,
Args: true,
},
{
Name: "build",
Aliases: []string{"b"},
Usage: "Build the project",
UsageText: "lux build [path/to/package]\n\n" + "Example:\n" + " lux build .",
Action: buildAppCommand,
Args: true,
},
{
Name: "run",
Aliases: []string{"r"},
Usage: "Run the project",
UsageText: "lux run [path/to/package]\n\n" + "Example:\n" + " lux run .",
Action: runAppCommand,
Args: true,
},
{
Name: "generate",
Aliases: []string{"g"},
Usage: "Generate a file or a directory",
UsageText: "lux generate [command] [path/to/package]\n\n" + "Example:\n" + " lux generate middleware middleware/acl",
Subcommands: []*cli.Command{
{
Name: "cmd",
Aliases: []string{"e"},
Usage: "Generate a command",
Args: true,
Action: generateCommand,
},
{
Name: "component",
Aliases: []string{"cp"},
Usage: "Generate a component",
Args: true,
Action: generateComponentsSetCommand,
},
{
Name: "middleware",
Aliases: []string{"m"},
Usage: "Generate a middleware",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "request",
Aliases: []string{"r"},
Usage: "Generate a request middleware",
Value: false,
Category: "middleware",
},
&cli.BoolFlag{
Name: "response",
Aliases: []string{"s"},
Usage: "Generate a response middleware",
Value: false,
Category: "middleware",
},
},
Args: true,
Action: generateMiddlewareCommand,
},
{
Name: "service",
Aliases: []string{"s"},
Usage: "Generate a service",
Args: true,
Action: generateServiceCommand,
},
{
Name: "controller",
Aliases: []string{"co"},
Usage: "Generate a controller",
Args: true,
Action: generateControllerCommand,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "get",
Aliases: []string{"g"},
Usage: "Generate a GET controller",
Value: false,
},
&cli.BoolFlag{
Name: "post",
Aliases: []string{"p"},
Usage: "Generate a POST controller",
Value: false,
},
&cli.BoolFlag{
Name: "put",
Aliases: []string{"u"},
Usage: "Generate a PUT controller",
Value: false,
},
&cli.BoolFlag{
Name: "patch",
Aliases: []string{"a"},
Usage: "Generate a PATCH controller",
Value: false,
},
&cli.BoolFlag{
Name: "delete",
Aliases: []string{"d"},
Usage: "Generate a DELETE controller",
Value: false,
},
&cli.BoolFlag{
Name: "socket",
Aliases: []string{"w"},
Usage: "Generate a SOCKET controller",
Value: false,
},
},
},
},
},
},
}
if err := app.Run(os.Args); err != nil {
panic(err)
}
}