-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
59 lines (49 loc) · 1.09 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
package main
import (
"os"
"strings"
"github.com/SierraSoftworks/inki/client"
"github.com/SierraSoftworks/inki/server"
log "github.com/Sirupsen/logrus"
"github.com/urfave/cli"
)
var version = "v1.0.0"
func main() {
app := cli.NewApp()
app.Name = "Inki"
app.Author = "Benjamin Pannell"
app.Email = "[email protected]"
app.Version = version
app.UsageText = "An SSH key distribution tool"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "log-level, L",
Value: "WARN",
Usage: "Log level to use (ERROR, WARN, INFO, DEBUG)",
},
}
app.Before = func(c *cli.Context) error {
logLevel := strings.ToUpper(c.String("log-level"))
switch logLevel {
case "ERROR":
log.SetLevel(log.ErrorLevel)
case "WARN":
log.SetLevel(log.WarnLevel)
case "INFO":
log.SetLevel(log.InfoLevel)
case "DEBUG":
log.SetLevel(log.DebugLevel)
default:
log.SetLevel(log.WarnLevel)
}
return nil
}
app.Commands = []cli.Command{
server.Command,
client.KeysCommands,
}
err := app.Run(os.Args)
if err != nil {
log.WithError(err).Fatal("Failed to run application")
}
}