-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.go
86 lines (76 loc) · 2.44 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"fmt"
"log"
"os"
"sort"
"time"
"github.com/urfave/cli/v2"
"github.com/hekmekk/git-team/src/shared/cli/effects"
addcmdadapter "github.com/hekmekk/git-team/src/command/assignments/add/cliadapter/cmd"
assignmentscmdadapter "github.com/hekmekk/git-team/src/command/assignments/cliadapter/cmd"
listcmdadapter "github.com/hekmekk/git-team/src/command/assignments/list/cliadapter/cmd"
removecmdadapter "github.com/hekmekk/git-team/src/command/assignments/remove/cliadapter/cmd"
completioncmdadapter "github.com/hekmekk/git-team/src/command/completion/cliadapter/cmd"
configcmdadapter "github.com/hekmekk/git-team/src/command/config/cliadapter/cmd"
disablecmdadapter "github.com/hekmekk/git-team/src/command/disable/cliadapter/cmd"
enablecmdadapter "github.com/hekmekk/git-team/src/command/enable/cliadapter/cmd"
statuscmdadapter "github.com/hekmekk/git-team/src/command/status/cliadapter/cmd"
)
const (
version = "1.9.0alpha1"
authorName = "Rea Sand"
authorEmail = "hekmek@posteo.de"
)
func main() {
application := newApplication()
err := application.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
func newApplication() *cli.App {
app := &cli.App{
Name: "git-team",
Compiled: time.Now(),
Version: version,
Authors: []*cli.Author{
&cli.Author{
Name: authorName,
Email: authorEmail,
},
},
Usage: "Command line interface for managing and enhancing git commit messages with co-authors.",
EnableBashCompletion: true,
HideHelp: false,
HideVersion: false,
Flags: []cli.Flag{
&cli.BoolFlag{Name: "generate-man-page", Value: false, Usage: "Generate man page for this"},
},
Commands: []*cli.Command{
enablecmdadapter.Command(),
disablecmdadapter.Command(),
statuscmdadapter.Command(),
assignmentscmdadapter.Command(),
addcmdadapter.Command(),
listcmdadapter.Command(),
removecmdadapter.Command(),
configcmdadapter.Command(),
completioncmdadapter.Command(),
},
Action: func(c *cli.Context) error {
shouldGenerateManPage := c.Bool("generate-man-page")
if shouldGenerateManPage {
manPage, err := c.App.ToMan()
if err != nil {
return effects.NewExitErrMsg(fmt.Errorf("failed to generate man page: %s", err)).Run()
}
return effects.NewExitOkMsg(manPage).Run()
}
return enablecmdadapter.Command().Action(c)
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
return app
}