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"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Commands returns the mapping of CLI commands for Vault. The meta
|
|
|
|
// 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{
|
|
|
|
Writer: os.Stdout,
|
|
|
|
ErrorWriter: os.Stderr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return map[string]cli.CommandFactory{
|
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
|
|
|
|
},
|
|
|
|
|
2015-09-11 19:31:13 +00:00
|
|
|
"agent-force-leave": func() (cli.Command, error) {
|
|
|
|
return &command.AgentForceLeaveCommand{
|
2015-09-14 20:13:52 +00:00
|
|
|
Meta: meta,
|
2015-09-11 19:31:13 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-09-11 17:50:39 +00:00
|
|
|
"agent-info": func() (cli.Command, error) {
|
|
|
|
return &command.AgentInfoCommand{
|
2015-09-14 20:13:52 +00:00
|
|
|
Meta: meta,
|
2015-09-11 17:50:39 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-09-11 22:48:36 +00:00
|
|
|
"agent-join": func() (cli.Command, error) {
|
|
|
|
return &command.AgentJoinCommand{
|
2015-09-14 20:13:52 +00:00
|
|
|
Meta: meta,
|
2015-09-11 22:48:36 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-09-11 19:58:16 +00:00
|
|
|
"agent-members": func() (cli.Command, error) {
|
|
|
|
return &command.AgentMembersCommand{
|
2015-09-14 20:13:52 +00:00
|
|
|
Meta: meta,
|
2015-09-11 19:58:16 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-09-13 00:09:03 +00:00
|
|
|
"node-drain": func() (cli.Command, error) {
|
|
|
|
return &command.NodeDrainCommand{
|
2015-09-14 20:13:52 +00:00
|
|
|
Meta: meta,
|
2015-09-13 00:09:03 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-09-12 20:55:51 +00:00
|
|
|
"node-status": func() (cli.Command, error) {
|
|
|
|
return &command.NodeStatusCommand{
|
2015-09-14 20:13:52 +00:00
|
|
|
Meta: meta,
|
2015-09-12 20:55:51 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-09-11 06:05:59 +00:00
|
|
|
"status": func() (cli.Command, error) {
|
|
|
|
return &command.StatusCommand{
|
2015-09-14 20:13:52 +00:00
|
|
|
Meta: meta,
|
2015-09-11 06:05:59 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-06-01 11:46:21 +00:00
|
|
|
"version": func() (cli.Command, error) {
|
|
|
|
ver := Version
|
|
|
|
rel := VersionPrerelease
|
|
|
|
if GitDescribe != "" {
|
|
|
|
ver = GitDescribe
|
|
|
|
}
|
|
|
|
if GitDescribe == "" && rel == "" && VersionPrerelease != "" {
|
|
|
|
rel = "dev"
|
|
|
|
}
|
|
|
|
|
|
|
|
return &command.VersionCommand{
|
|
|
|
Revision: GitCommit,
|
|
|
|
Version: ver,
|
|
|
|
VersionPrerelease: rel,
|
|
|
|
Ui: meta.Ui,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|