github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/plugins/shared/cmd/launcher/main.go (about)

     1  package main
     2  
     3  import (
     4  	"os"
     5  
     6  	hclog "github.com/hashicorp/go-hclog"
     7  	"github.com/hashicorp/nomad/plugins/shared/cmd/launcher/command"
     8  	"github.com/mitchellh/cli"
     9  )
    10  
    11  const (
    12  	NomadPluginLauncherCli        = "nomad-plugin-launcher"
    13  	NomadPluginLauncherCliVersion = "0.0.1"
    14  )
    15  
    16  func main() {
    17  	ui := &cli.BasicUi{
    18  		Reader:      os.Stdin,
    19  		Writer:      os.Stdout,
    20  		ErrorWriter: os.Stderr,
    21  	}
    22  
    23  	logger := hclog.New(&hclog.LoggerOptions{
    24  		Name:   NomadPluginLauncherCli,
    25  		Output: &cli.UiWriter{Ui: ui},
    26  	})
    27  
    28  	c := cli.NewCLI(NomadPluginLauncherCli, NomadPluginLauncherCliVersion)
    29  	c.Args = os.Args[1:]
    30  
    31  	meta := command.NewMeta(ui, logger)
    32  	c.Commands = map[string]cli.CommandFactory{
    33  		"device": command.DeviceCommandFactory(meta),
    34  	}
    35  
    36  	exitStatus, err := c.Run()
    37  	if err != nil {
    38  		logger.Error("command exited with non-zero status", "status", exitStatus, "error", err)
    39  	}
    40  	os.Exit(exitStatus)
    41  }