-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
65 lines (59 loc) · 1.32 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 (
"fmt"
"log"
"log/slog"
"os"
"github.com/d3witt/dockboy/cli/command"
"github.com/d3witt/dockboy/cli/command/app"
"github.com/d3witt/dockboy/cli/command/machine"
"github.com/d3witt/dockboy/streams"
"github.com/urfave/cli/v2"
)
var version = "dev" // set by build script
func main() {
dockboyCli := &command.Cli{
In: streams.StdIn,
Out: streams.StdOut,
Err: streams.StdErr,
}
app := &cli.App{
Name: "dockboy",
Usage: "Deploy your apps anywhere",
Version: version,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "debug",
Usage: "Enable debug output",
},
},
Before: func(ctx *cli.Context) error {
if ctx.Bool("debug") {
slog.SetLogLoggerLevel(slog.LevelDebug)
}
return nil
},
Commands: []*cli.Command{
app.NewInitCmd(dockboyCli),
app.NewDeployCmd(dockboyCli),
app.NewLogsCommand(dockboyCli),
app.NewDestroyCmd(dockboyCli),
app.NewInfoCmd(dockboyCli),
machine.NewPurgeCmd(dockboyCli),
machine.NewExecuteCmd(dockboyCli),
},
Suggest: true,
Reader: dockboyCli.In,
Writer: dockboyCli.Out,
ErrWriter: dockboyCli.Err,
ExitErrHandler: func(ctx *cli.Context, err error) {
if err != nil {
fmt.Fprintf(dockboyCli.Err, "error: %v\n", err)
os.Exit(0)
}
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}