-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
65 lines (57 loc) · 1.1 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
package main
import (
"gee/cmd"
"gee/pkg/util"
"os"
"github.com/go-playground/validator/v10"
"github.com/urfave/cli/v2"
)
var (
app *cli.App
version = "dev"
)
var validate *validator.Validate
func main() {
app.Flags = []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Usage: "Enable verbose logging",
},
}
app.Before = func(c *cli.Context) error {
verbose := c.Bool("verbose")
util.SetVerbose(verbose)
if verbose {
util.VerboseLog("Verbose logging enabled")
}
return nil
}
app.Commands = []*cli.Command{
cmd.InitCmd(),
cmd.AddCmd(),
cmd.PullCmd(),
cmd.StatusCmd(),
cmd.CloneCmd(),
cmd.RemoveCmd(),
}
// Run the CLI app
err := app.Run(os.Args)
if err != nil {
switch err.(type) {
case *util.InfoError:
util.Info("%s", err.Error())
case *util.WarningError:
util.Warning("%s", err.Error())
default:
util.CheckIfError(err)
}
}
}
func init() {
validate = validator.New()
// Initialise a CLI app
app = cli.NewApp()
app.Name = "gee"
app.Usage = "Gee gives user's control of git commands across repos without moving between them."
app.Version = version
}