-
Notifications
You must be signed in to change notification settings - Fork 67
/
main.go
57 lines (50 loc) · 1.12 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
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
"github.com/xeals/signal-back/cmd"
"github.com/xeals/signal-back/types"
)
var version = "devel"
func main() {
cli.VersionPrinter = func(c *cli.Context) {
fmt.Printf("signal-back %s\nproto commit: %s\n", version, types.ProtoCommitHash)
}
app := cli.NewApp()
app.CustomAppHelpTemplate = cmd.AppHelp
app.Version = version
app.Commands = []cli.Command{
cmd.Format,
cmd.Analyse,
cmd.Extract,
cmd.Check,
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "show help",
},
}
app.Action = func(c *cli.Context) error {
return cli.ShowAppHelp(c)
}
// app.Action = cli.ActionFunc(func(c *cli.Context) error {
// // -- Logging
// if c.String("log") != "" {
// f, err := os.OpenFile(c.String("log"), os.O_CREATE|os.O_WRONLY, 0644)
// if err != nil {
// return errors.Wrap(err, "unable to create logging file")
// }
// logger = f
// } else {
// logger = os.Stderr
// }
// return nil
// })
if err := app.Run(os.Args); err != nil {
// log.Fatalln(err)
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
}