forked from runabol/tork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
50 lines (42 loc) · 742 Bytes
/
cli.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
package cli
import (
"os"
"github.com/runabol/tork/internal/logging"
"github.com/runabol/tork/internal/reexec"
ucli "github.com/urfave/cli/v2"
)
type CLI struct {
app *ucli.App
}
func New() *CLI {
app := &ucli.App{
Name: "tork",
Usage: "a distributed workflow engine",
}
c := &CLI{
app: app,
}
app.Before = c.before
app.Commands = c.commands()
return c
}
func (c *CLI) Run() error {
if reexec.Init() {
return nil
}
return c.app.Run(os.Args)
}
func (c *CLI) before(ctx *ucli.Context) error {
displayBanner()
if err := logging.SetupLogging(); err != nil {
return err
}
return nil
}
func (c *CLI) commands() []*ucli.Command {
return []*ucli.Command{
c.runCmd(),
c.migrationCmd(),
c.healthCmd(),
}
}