github.com/dkerwin/nomad@v0.3.3-0.20160525181927-74554135514b/commands.go (about) 1 package main 2 3 import ( 4 "os" 5 6 "github.com/hashicorp/nomad/command" 7 "github.com/hashicorp/nomad/command/agent" 8 "github.com/mitchellh/cli" 9 ) 10 11 // Commands returns the mapping of CLI commands for Nomad. The meta 12 // parameter lets you set meta options for all commands. 13 func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory { 14 if metaPtr == nil { 15 metaPtr = new(command.Meta) 16 } 17 18 meta := *metaPtr 19 if meta.Ui == nil { 20 meta.Ui = &cli.BasicUi{ 21 Reader: os.Stdin, 22 Writer: os.Stdout, 23 ErrorWriter: os.Stderr, 24 } 25 } 26 27 return map[string]cli.CommandFactory{ 28 "alloc-status": func() (cli.Command, error) { 29 return &command.AllocStatusCommand{ 30 Meta: meta, 31 }, nil 32 }, 33 "agent": func() (cli.Command, error) { 34 return &agent.Command{ 35 Revision: GitCommit, 36 Version: Version, 37 VersionPrerelease: VersionPrerelease, 38 Ui: meta.Ui, 39 ShutdownCh: make(chan struct{}), 40 }, nil 41 }, 42 "agent-info": func() (cli.Command, error) { 43 return &command.AgentInfoCommand{ 44 Meta: meta, 45 }, nil 46 }, 47 "check": func() (cli.Command, error) { 48 return &command.AgentCheckCommand{ 49 Meta: meta, 50 }, nil 51 }, 52 "client-config": func() (cli.Command, error) { 53 return &command.ClientConfigCommand{ 54 Meta: meta, 55 }, nil 56 }, 57 "eval-monitor": func() (cli.Command, error) { 58 return &command.EvalMonitorCommand{ 59 Meta: meta, 60 }, nil 61 }, 62 "executor": func() (cli.Command, error) { 63 return &command.ExecutorPluginCommand{ 64 Meta: meta, 65 }, nil 66 }, 67 "fs": func() (cli.Command, error) { 68 return &command.FSCommand{ 69 Meta: meta, 70 }, nil 71 }, 72 "init": func() (cli.Command, error) { 73 return &command.InitCommand{ 74 Meta: meta, 75 }, nil 76 }, 77 "inspect": func() (cli.Command, error) { 78 return &command.InspectCommand{ 79 Meta: meta, 80 }, nil 81 }, 82 "node-drain": func() (cli.Command, error) { 83 return &command.NodeDrainCommand{ 84 Meta: meta, 85 }, nil 86 }, 87 "node-status": func() (cli.Command, error) { 88 return &command.NodeStatusCommand{ 89 Meta: meta, 90 }, nil 91 }, 92 93 "plan": func() (cli.Command, error) { 94 return &command.PlanCommand{ 95 Meta: meta, 96 }, nil 97 }, 98 99 "run": func() (cli.Command, error) { 100 return &command.RunCommand{ 101 Meta: meta, 102 }, nil 103 }, 104 "syslog": func() (cli.Command, error) { 105 return &command.SyslogPluginCommand{ 106 Meta: meta, 107 }, nil 108 }, 109 "server-force-leave": func() (cli.Command, error) { 110 return &command.ServerForceLeaveCommand{ 111 Meta: meta, 112 }, nil 113 }, 114 "server-join": func() (cli.Command, error) { 115 return &command.ServerJoinCommand{ 116 Meta: meta, 117 }, nil 118 }, 119 "server-members": func() (cli.Command, error) { 120 return &command.ServerMembersCommand{ 121 Meta: meta, 122 }, nil 123 }, 124 "status": func() (cli.Command, error) { 125 return &command.StatusCommand{ 126 Meta: meta, 127 }, nil 128 }, 129 "stop": func() (cli.Command, error) { 130 return &command.StopCommand{ 131 Meta: meta, 132 }, nil 133 }, 134 "validate": func() (cli.Command, error) { 135 return &command.ValidateCommand{ 136 Meta: meta, 137 }, nil 138 }, 139 "version": func() (cli.Command, error) { 140 ver := Version 141 rel := VersionPrerelease 142 if GitDescribe != "" { 143 ver = GitDescribe 144 // Trim off a leading 'v', we append it anyways. 145 if ver[0] == 'v' { 146 ver = ver[1:] 147 } 148 } 149 if GitDescribe == "" && rel == "" && VersionPrerelease != "" { 150 rel = "dev" 151 } 152 153 return &command.VersionCommand{ 154 Revision: GitCommit, 155 Version: ver, 156 VersionPrerelease: rel, 157 Ui: meta.Ui, 158 }, nil 159 }, 160 } 161 }