-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
48 lines (41 loc) · 1007 Bytes
/
cli.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 cli
import (
"sort"
"github.com/urfave/cli"
"github.com/Place1/swagger-version-manager/commands"
)
func Run(args []string) error {
app := cli.NewApp()
app.Name = "swagger-version-manager"
app.Version = "1.0.1"
app.Commands = []cli.Command{
{
Name: "current",
Usage: "show the current swagger codegen version",
Action: func(context *cli.Context) error {
return commands.Current()
},
},
{
Name: "list",
Usage: "list available swagger codegen versions",
Action: func(context *cli.Context) error {
return commands.List()
},
},
{
Name: "use",
Usage: "use the specified swagger-codegen-version",
ArgsUsage: "<version>",
Action: func(context *cli.Context) error {
version := context.Args().First()
if version == "" {
return cli.NewExitError("please provide version string", 1)
}
return commands.Use(context.Args().First())
},
},
}
sort.Sort(cli.CommandsByName(app.Commands))
return app.Run(args)
}