mirror of https://github.com/docker/docs.git
Add a version command
Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
parent
43d9df3216
commit
1521fed1ed
|
|
@ -71,7 +71,7 @@ OPTIONS:
|
|||
var helpCommand = Command{
|
||||
Name: "help",
|
||||
Aliases: []string{"h"},
|
||||
Usage: "Shows a list of commands or help for one command",
|
||||
Usage: "Show a list of commands or help for one command",
|
||||
ArgsUsage: "[command]",
|
||||
Action: func(c *Context) {
|
||||
args := c.Args()
|
||||
|
|
@ -86,7 +86,7 @@ var helpCommand = Command{
|
|||
var helpSubcommand = Command{
|
||||
Name: "help",
|
||||
Aliases: []string{"h"},
|
||||
Usage: "Shows a list of commands or help for one command",
|
||||
Usage: "Show a list of commands or help for one command",
|
||||
ArgsUsage: "[command]",
|
||||
Action: func(c *Context) {
|
||||
args := c.Args()
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ func main() {
|
|||
app.Commands = commands.Commands
|
||||
app.CommandNotFound = cmdNotFound
|
||||
app.Usage = "Create and manage machines running Docker."
|
||||
app.Version = version.Version + " (" + version.GitCommit + ")"
|
||||
app.Version = version.FullVersion()
|
||||
|
||||
log.Debug("Docker Machine Version: ", app.Version)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ var (
|
|||
type CommandLine interface {
|
||||
ShowHelp()
|
||||
|
||||
ShowVersion()
|
||||
|
||||
Application() *cli.App
|
||||
|
||||
Args() cli.Args
|
||||
|
|
@ -54,6 +56,10 @@ func (c *contextCommandLine) ShowHelp() {
|
|||
cli.ShowCommandHelp(c.Context, c.Command.Name)
|
||||
}
|
||||
|
||||
func (c *contextCommandLine) ShowVersion() {
|
||||
cli.ShowVersion(c.Context)
|
||||
}
|
||||
|
||||
func (c *contextCommandLine) Application() *cli.App {
|
||||
return c.App
|
||||
}
|
||||
|
|
@ -347,6 +353,11 @@ var Commands = []cli.Command{
|
|||
Description: "Argument is a machine name.",
|
||||
Action: fatalOnError(cmdURL),
|
||||
},
|
||||
{
|
||||
Name: "version",
|
||||
Usage: "Show the Docker Machine version information",
|
||||
Action: fatalOnError(cmdVersion),
|
||||
},
|
||||
}
|
||||
|
||||
func printIP(h *host.Host) func() error {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
package commands
|
||||
|
||||
func cmdVersion(c CommandLine) error {
|
||||
c.ShowVersion()
|
||||
return nil
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package version
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
// Version should be updated by hand at each release
|
||||
Version = "0.5.2-dev"
|
||||
|
|
@ -7,3 +9,8 @@ var (
|
|||
// GitCommit will be overwritten automatically by the build system
|
||||
GitCommit = "HEAD"
|
||||
)
|
||||
|
||||
// FullVersion formats the version to be printed
|
||||
func FullVersion() string {
|
||||
return fmt.Sprintf("%s ( %s )", Version, GitCommit)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue