github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/mitchellh/cli" 8 "github.com/sean-/seed" 9 ) 10 11 func init() { 12 seed.Init() 13 } 14 15 func main() { 16 os.Exit(Run(os.Args[1:])) 17 } 18 19 func Run(args []string) int { 20 return RunCustom(args, Commands(nil)) 21 } 22 23 func RunCustom(args []string, commands map[string]cli.CommandFactory) int { 24 // Build the commands to include in the help now. 25 commandsInclude := make([]string, 0, len(commands)) 26 for k, _ := range commands { 27 switch k { 28 case "check": 29 case "deployment list", "deployment status", "deployment pause", 30 "deployment resume", "deployment fail", "deployment promote": 31 case "executor": 32 case "fs ls", "fs cat", "fs stat": 33 case "job deployments", "job dispatch", "job history", "job promote", "job revert": 34 case "operator raft", "operator raft list-peers", "operator raft remove-peer": 35 case "syslog": 36 default: 37 commandsInclude = append(commandsInclude, k) 38 } 39 } 40 41 cli := &cli.CLI{ 42 Name: "nomad", 43 Version: PrettyVersion(GetVersionParts()), 44 Args: args, 45 Commands: commands, 46 Autocomplete: true, 47 HelpFunc: cli.FilteredHelpFunc(commandsInclude, cli.BasicHelpFunc("nomad")), 48 } 49 50 exitCode, err := cli.Run() 51 if err != nil { 52 fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error()) 53 return 1 54 } 55 56 return exitCode 57 }