55 "io/ioutil"
66 "os"
77
8+ "github.com/docker/app/internal"
9+
810 "github.com/docker/app/internal/store"
911 "github.com/docker/cli/cli/command"
1012 "github.com/docker/cli/cli/config"
@@ -13,7 +15,8 @@ import (
1315)
1416
1517var (
16- completion string
18+ completion string
19+ showVersion bool
1720)
1821
1922// NewRootCmd returns the base root command.
@@ -24,6 +27,11 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
2427 Use : use ,
2528 Annotations : map [string ]string {"experimentalCLI" : "true" },
2629 RunE : func (cmd * cobra.Command , args []string ) error {
30+ if showVersion {
31+ fmt .Fprintln (os .Stdout , internal .FullVersion ()) //nolint:errcheck
32+ return nil
33+ }
34+
2735 switch completion {
2836 case "bash" :
2937 return cmd .GenBashCompletion (dockerCli .Out ())
@@ -41,10 +49,11 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
4149
4250 cmd .Flags ().StringVar (& completion , "completion" , "" , "Generates completion scripts for the specified shell (bash or zsh)" )
4351 if err := cmd .Flags ().MarkHidden ("completion" ); err != nil {
44- _ , _ = fmt .Fprintf (os .Stderr , "Failed to register command line options: %v" , err .Error ())
52+ fmt .Fprintf (os .Stderr , "Failed to register command line options: %v" , err .Error ()) //nolint:errcheck
4553 return nil
4654 }
4755
56+ cmd .Flags ().BoolVar (& showVersion , "version" , false , "Print version information" )
4857 return cmd
4958}
5059
@@ -59,7 +68,6 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
5968 inspectCmd (dockerCli ),
6069 renderCmd (dockerCli ),
6170 validateCmd (),
62- versionCmd (dockerCli ),
6371 bundleCmd (dockerCli ),
6472 pushCmd (dockerCli ),
6573 pullCmd (dockerCli ),
0 commit comments