-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
70 lines (65 loc) · 1.56 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
package main
import (
"fmt"
"os"
"github.com/rubiojr/rapi"
"github.com/swampapp/swamp/internal/logger"
"github.com/swampapp/swamp/internal/version"
"github.com/urfave/cli/v2"
)
var appCommands []*cli.Command
var globalOptions = rapi.DefaultOptions
var indexPath string
func main() {
var err error
app := &cli.App{
Name: "swampd",
Commands: []*cli.Command{},
Version: fmt.Sprintf("swampd v%s (%s)\n", version.APP_VERSION, version.GIT_SHA),
Before: func(c *cli.Context) error {
if c.Bool("debug") {
logger.Init(logger.DebugLevel, "swampd")
} else {
logger.Init(logger.InfoLevel, "swampd")
}
return nil
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "repo",
Aliases: []string{"r"},
EnvVars: []string{"RESTIC_REPOSITORY"},
Usage: "Repository path",
Required: false,
Destination: &globalOptions.Repo,
},
&cli.StringFlag{
Name: "password",
Aliases: []string{"p"},
EnvVars: []string{"RESTIC_PASSWORD"},
Usage: "Repository password",
Required: false,
Destination: &globalOptions.Password,
DefaultText: " ",
},
&cli.StringFlag{
Name: "index-path",
Usage: "Index path",
Required: true,
Destination: &indexPath,
},
&cli.BoolFlag{
Name: "debug",
Aliases: []string{"d"},
Usage: "Enable debugging",
Required: false,
},
},
}
app.Commands = append(app.Commands, appCommands...)
err = app.Run(os.Args)
if err != nil {
println(fmt.Sprintf("\n🛑 %s", err))
os.Exit(1)
}
}