-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathroot.go
52 lines (46 loc) · 901 Bytes
/
root.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
package cmd
import (
"os"
"github.com/matsuyoshi30/gitsu/cmd/prompts"
"github.com/urfave/cli/v2"
)
func Execute() error {
app := &cli.App{
Name: "gitsu",
Usage: "Easily switch between multiple git users",
Commands: []*cli.Command{
DeleteCommand(),
ModifyCommand(),
SelectCommand(),
ResetCommand(),
InitCommand(),
AddCommand(),
},
Action: func(c *cli.Context) error {
action, _, err := prompts.SelectionCustom(
"Select action",
[]string{
"Select user",
"Add new user",
"Delete user",
"Modify user",
},
)
if err != nil {
return err
}
switch action {
case 0:
return c.App.Command("select").Run(c)
case 1:
return c.App.Command("add").Run(c)
case 2:
return c.App.Command("delete").Run(c)
case 3:
return c.App.Command("modify").Run(c)
}
return nil
},
}
return app.Run(os.Args)
}