forked from hekmekk/git-team
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-team.go
51 lines (41 loc) · 1.59 KB
/
git-team.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
package main
import (
"github.com/hekmekk/git-team/core/handler"
"gopkg.in/alecthomas/kingpin.v2"
"os"
)
const (
version = "v1.0.1"
author = "Rea Sand <[email protected]>"
)
func main() {
app := kingpin.New("git-team", "Command line interface for creating git commit templates provisioned with one or more co-authors. Please note that \"git commit -m\" is not affected by commit templates.")
app.HelpFlag.Short('h')
app.Version(version)
app.Author(author)
enable := app.Command("enable", "Provisions a git-commit template with the provided co-authors. A co-author must either be an alias or of the shape \"Name <email>\"").Default()
coauthors := enable.Arg("coauthors", "Git co-authors").Strings()
disable := app.Command("disable", "Use default template")
status := app.Command("status", "Print the current status")
add := app.Command("add", "Add an alias")
addAlias := add.Arg("alias", "The alias to be added").Required().String()
addCoauthor := add.Arg("coauthor", "The co-author").Required().String()
rm := app.Command("rm", "Remove an alias")
rmAlias := rm.Arg("alias", "The alias to be removed").Required().String()
list := app.Command("list", "List currently available aliases")
list.Alias("ls")
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
case enable.FullCommand():
handler.EnableCommand(coauthors)
case disable.FullCommand():
handler.DisableCommand()
case status.FullCommand():
handler.Status()
case add.FullCommand():
handler.AddCommand(addAlias, addCoauthor)
case rm.FullCommand():
handler.RemoveCommand(rmAlias)
case list.FullCommand():
handler.ListCommand()
}
}