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{
|
var helpCommand = Command{
|
||||||
Name: "help",
|
Name: "help",
|
||||||
Aliases: []string{"h"},
|
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]",
|
ArgsUsage: "[command]",
|
||||||
Action: func(c *Context) {
|
Action: func(c *Context) {
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
|
|
@ -86,7 +86,7 @@ var helpCommand = Command{
|
||||||
var helpSubcommand = Command{
|
var helpSubcommand = Command{
|
||||||
Name: "help",
|
Name: "help",
|
||||||
Aliases: []string{"h"},
|
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]",
|
ArgsUsage: "[command]",
|
||||||
Action: func(c *Context) {
|
Action: func(c *Context) {
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ func main() {
|
||||||
app.Commands = commands.Commands
|
app.Commands = commands.Commands
|
||||||
app.CommandNotFound = cmdNotFound
|
app.CommandNotFound = cmdNotFound
|
||||||
app.Usage = "Create and manage machines running Docker."
|
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)
|
log.Debug("Docker Machine Version: ", app.Version)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ var (
|
||||||
type CommandLine interface {
|
type CommandLine interface {
|
||||||
ShowHelp()
|
ShowHelp()
|
||||||
|
|
||||||
|
ShowVersion()
|
||||||
|
|
||||||
Application() *cli.App
|
Application() *cli.App
|
||||||
|
|
||||||
Args() cli.Args
|
Args() cli.Args
|
||||||
|
|
@ -54,6 +56,10 @@ func (c *contextCommandLine) ShowHelp() {
|
||||||
cli.ShowCommandHelp(c.Context, c.Command.Name)
|
cli.ShowCommandHelp(c.Context, c.Command.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *contextCommandLine) ShowVersion() {
|
||||||
|
cli.ShowVersion(c.Context)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *contextCommandLine) Application() *cli.App {
|
func (c *contextCommandLine) Application() *cli.App {
|
||||||
return c.App
|
return c.App
|
||||||
}
|
}
|
||||||
|
|
@ -347,6 +353,11 @@ var Commands = []cli.Command{
|
||||||
Description: "Argument is a machine name.",
|
Description: "Argument is a machine name.",
|
||||||
Action: fatalOnError(cmdURL),
|
Action: fatalOnError(cmdURL),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "version",
|
||||||
|
Usage: "Show the Docker Machine version information",
|
||||||
|
Action: fatalOnError(cmdVersion),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func printIP(h *host.Host) func() error {
|
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
|
package version
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Version should be updated by hand at each release
|
// Version should be updated by hand at each release
|
||||||
Version = "0.5.2-dev"
|
Version = "0.5.2-dev"
|
||||||
|
|
@ -7,3 +9,8 @@ var (
|
||||||
// GitCommit will be overwritten automatically by the build system
|
// GitCommit will be overwritten automatically by the build system
|
||||||
GitCommit = "HEAD"
|
GitCommit = "HEAD"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// FullVersion formats the version to be printed
|
||||||
|
func FullVersion() string {
|
||||||
|
return fmt.Sprintf("%s ( %s )", Version, GitCommit)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue