-
Notifications
You must be signed in to change notification settings - Fork 30
/
cmd.go
44 lines (40 loc) · 1.38 KB
/
cmd.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
package cmd
import (
"fmt"
executorCmd "github.com/synapsecns/sanguine/agents/agents/executor/cmd"
guardCmd "github.com/synapsecns/sanguine/agents/agents/guard/cmd"
notaryCmd "github.com/synapsecns/sanguine/agents/agents/notary/cmd"
"github.com/synapsecns/sanguine/core/commandline"
"github.com/synapsecns/sanguine/core/config"
"github.com/synapsecns/sanguine/core/metrics"
"github.com/urfave/cli/v2"
)
// Start starts the command line.
func Start(args []string, buildInfo config.BuildInfo) {
app := cli.NewApp()
app.Name = buildInfo.Name()
app.Description = buildInfo.VersionString() + "agents is used to access all Sanguine agents"
app.Usage = fmt.Sprintf("%s --help", buildInfo.Name())
app.EnableBashCompletion = true
// TODO: should we really halt boot on because of metrics?
app.Before = func(c *cli.Context) error {
// nolint:wrapcheck
return metrics.Setup(c.Context, buildInfo)
}
// commands
app.Commands = cli.Commands{
// Executor Commands
executorCmd.ExecutorInfoCommand, executorCmd.ExecutorRunCommand,
// Notary Commands
notaryCmd.NotaryInfoCommand, notaryCmd.NotaryRunCommand,
// Guard Commands
guardCmd.GuardInfoCommand, guardCmd.GuardRunCommand,
}
shellCommand := commandline.GenerateShellCommand(app.Commands)
app.Commands = append(app.Commands, shellCommand)
app.Action = shellCommand.Action
err := app.Run(args)
if err != nil {
panic(err)
}
}