-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
64 lines (56 loc) · 1.42 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
package main
import (
"fmt"
"os"
"github.com/codegangsta/cli"
"github.com/gutengo/shell"
)
func main() {
cli.AppHelpTemplate = `{{.Name}} v{{.Version}} - {{.Usage}}
USAGE:
{{.Name}} {{if .Flags}}[options] {{end}}<template ..>
COMMANDS:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
GLOBAL OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{end}}
`
app := cli.NewApp()
app.Name = "gutgenerator"
app.Usage = "a generic project generator"
app.Version = "0.0.1"
app.Action = func(c *cli.Context) {
cli.ShowAppHelp(c)
}
app.Commands = []cli.Command{
{
Name: "new",
Usage: "create a new project",
Action: func(c *cli.Context) {
if len(c.Args()) < 2 {
shell.ErrorExit("arguments length < 2\nUSAGE: gutgenerator new <template> <project>")
}
New(c.Args()[0], c.Args()[1])
},
}, {
Name: "add",
Usage: "add more templates in current directory",
Action: func(c *cli.Context) {
args := c.Args()
if len(args) < 1 {
shell.ErrorExit("arguments length < 1\nUSAGE: gutgenerator add <template> [name]")
}
Add(args.Get(0), args.Get(1))
},
},
{
Name: "list",
Usage: "list all templates",
Action: func(c *cli.Context) {
fmt.Println("list", c.Args())
},
},
}
app.Run(os.Args)
}