commands: add version command

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2019-04-24 16:16:30 -07:00
parent e7e57b626d
commit 6abbf0ee76
2 changed files with 28 additions and 0 deletions

View File

@ -34,6 +34,7 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
stopCmd(dockerCli),
installCmd(dockerCli),
uninstallCmd(dockerCli),
versionCmd(dockerCli),
imagetoolscmd.RootCmd(dockerCli),
)
}

27
commands/version.go Normal file
View File

@ -0,0 +1,27 @@
package commands
import (
"fmt"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/spf13/cobra"
"github.com/tonistiigi/buildx/version"
)
func runVersion(dockerCli command.Cli) error {
fmt.Println(version.Package, version.Version, version.Revision)
return nil
}
func versionCmd(dockerCli command.Cli) *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Show buildx version information ",
Args: cli.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
return runVersion(dockerCli)
},
}
return cmd
}