synapsecns/sanguine

View on GitHub
agents/cmd/cmd.go

Summary

Maintainability
A
0 mins
Test Coverage
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)
    }
}