open-nomad/commands.go

176 lines
3.6 KiB
Go
Raw Normal View History

2015-06-01 11:46:21 +00:00
package main
import (
"os"
2015-06-01 13:25:51 +00:00
"github.com/hashicorp/nomad/command"
2015-08-16 01:34:47 +00:00
"github.com/hashicorp/nomad/command/agent"
2015-06-01 11:46:21 +00:00
"github.com/mitchellh/cli"
)
2015-09-20 20:37:11 +00:00
// Commands returns the mapping of CLI commands for Nomad. The meta
2015-06-01 11:46:21 +00:00
// parameter lets you set meta options for all commands.
func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
if metaPtr == nil {
metaPtr = new(command.Meta)
}
meta := *metaPtr
if meta.Ui == nil {
meta.Ui = &cli.BasicUi{
2016-03-24 21:43:20 +00:00
Reader: os.Stdin,
Writer: os.Stdout,
ErrorWriter: os.Stderr,
2015-06-01 11:46:21 +00:00
}
}
return map[string]cli.CommandFactory{
"alloc-status": func() (cli.Command, error) {
return &command.AllocStatusCommand{
Meta: meta,
}, nil
},
2015-08-16 01:34:47 +00:00
"agent": func() (cli.Command, error) {
return &agent.Command{
Revision: GitCommit,
Version: Version,
VersionPrerelease: VersionPrerelease,
Ui: meta.Ui,
ShutdownCh: make(chan struct{}),
}, nil
},
"agent-info": func() (cli.Command, error) {
return &command.AgentInfoCommand{
Meta: meta,
2015-09-11 19:31:13 +00:00
}, nil
},
"client-config": func() (cli.Command, error) {
return &command.ClientConfigCommand{
2015-09-25 04:31:15 +00:00
Meta: meta,
}, nil
},
"eval-monitor": func() (cli.Command, error) {
return &command.EvalMonitorCommand{
Meta: meta,
2015-09-11 17:50:39 +00:00
}, nil
},
2016-02-08 03:07:50 +00:00
"executor": func() (cli.Command, error) {
return &command.ExecutorPluginCommand{
Meta: meta,
}, nil
},
"fs": func() (cli.Command, error) {
return &command.FSCommand{
2016-02-02 22:36:11 +00:00
Meta: meta,
}, nil
},
2016-01-28 00:29:29 +00:00
"fs ls": func() (cli.Command, error) {
2016-01-26 22:31:52 +00:00
return &command.FSListCommand{
Meta: meta,
}, nil
},
2016-01-28 00:29:29 +00:00
"fs stat": func() (cli.Command, error) {
2016-01-26 23:03:26 +00:00
return &command.FSStatCommand{
Meta: meta,
}, nil
},
2016-01-28 00:29:29 +00:00
"fs cat": func() (cli.Command, error) {
2016-01-27 00:07:59 +00:00
return &command.FSCatCommand{
Meta: meta,
}, nil
},
2015-09-21 00:06:02 +00:00
"init": func() (cli.Command, error) {
return &command.InitCommand{
Meta: meta,
}, nil
},
2016-03-21 19:46:35 +00:00
"inspect": func() (cli.Command, error) {
return &command.InspectCommand{
Meta: meta,
}, nil
},
"node-drain": func() (cli.Command, error) {
return &command.NodeDrainCommand{
Meta: meta,
2015-09-11 22:48:36 +00:00
}, nil
},
"node-status": func() (cli.Command, error) {
return &command.NodeStatusCommand{
Meta: meta,
2015-09-11 19:58:16 +00:00
}, nil
},
"run": func() (cli.Command, error) {
return &command.RunCommand{
Meta: meta,
}, nil
},
"syslog": func() (cli.Command, error) {
return &command.SyslogPluginCommand{
Meta: meta,
}, nil
},
"server-force-leave": func() (cli.Command, error) {
return &command.ServerForceLeaveCommand{
Meta: meta,
2015-09-13 00:09:03 +00:00
}, nil
},
"server-join": func() (cli.Command, error) {
return &command.ServerJoinCommand{
Meta: meta,
2015-09-12 20:55:51 +00:00
}, nil
},
"server-members": func() (cli.Command, error) {
return &command.ServerMembersCommand{
2015-09-16 01:22:51 +00:00
Meta: meta,
}, nil
},
2015-09-11 06:05:59 +00:00
"status": func() (cli.Command, error) {
return &command.StatusCommand{
Meta: meta,
2015-09-11 06:05:59 +00:00
}, nil
},
2015-09-17 00:35:58 +00:00
"stop": func() (cli.Command, error) {
return &command.StopCommand{
Meta: meta,
}, nil
},
2015-09-25 01:29:46 +00:00
"validate": func() (cli.Command, error) {
return &command.ValidateCommand{
Meta: meta,
}, nil
},
2015-06-01 11:46:21 +00:00
"version": func() (cli.Command, error) {
ver := Version
rel := VersionPrerelease
if GitDescribe != "" {
ver = GitDescribe
// Trim off a leading 'v', we append it anyways.
if ver[0] == 'v' {
ver = ver[1:]
}
2015-06-01 11:46:21 +00:00
}
if GitDescribe == "" && rel == "" && VersionPrerelease != "" {
rel = "dev"
}
return &command.VersionCommand{
Revision: GitCommit,
Version: ver,
VersionPrerelease: rel,
Ui: meta.Ui,
}, nil
},
}
}