-
Notifications
You must be signed in to change notification settings - Fork 0
/
mgu.go
81 lines (73 loc) · 1.46 KB
/
mgu.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
package main
import (
"os"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli"
"gopkg.in/AlecAivazis/survey.v1/core"
)
var (
homeDirPath, _ = homedir.Dir()
configDirPath = homeDirPath + "/.config"
appConfigDirPath = configDirPath + "/mgu"
appConfigFilePath = appConfigDirPath + "/settign.json"
)
type User struct {
Name string `json:"name"`
Email string `json:"email"`
}
func main() {
core.ErrorIcon = "X"
core.SelectFocusIcon = ">"
core.MarkedOptionIcon = "[x]"
core.UnmarkedOptionIcon = "[ ]"
app := cli.NewApp()
app.Name = "mgu"
app.Usage = "Manage git local users"
app.Version = "0.0.1"
app.Action = func(c *cli.Context) error {
if c.Args().Get(0) == "" {
cmdShow(c)
} else {
cli.ShowCommandHelp(c, "")
}
return nil
}
app.Commands = []cli.Command{
{
Name: "init",
Aliases: []string{"i"},
Usage: "Create setting file",
Action: cmdInit,
},
{
Name: "show",
Aliases: []string{"s"},
Usage: "Show current Git's user",
Action: cmdShow,
},
{
Name: "add",
Aliases: []string{"a"},
Usage: "Add Git's local user",
Action: cmdAdd,
},
{
Name: "set",
Usage: "Setting Git's local user",
Action: cmdSet,
},
{
Name: "list",
Aliases: []string{"l"},
Usage: "Display Git's local users",
Action: cmdList,
},
{
Name: "remove",
Aliases: []string{"r"},
Usage: "Remove Git's local user",
Action: cmdRemove,
},
}
app.Run(os.Args)
}