summaryrefslogtreecommitdiff
path: root/cmd/podman/version.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-02-08 20:12:38 +0100
committerGitHub <noreply@github.com>2019-02-08 20:12:38 +0100
commitafd4d5f4a4b05f421e6f336b4d74a0d808be57ed (patch)
tree2ccb4a0bd9bda70c1c258dcb1b8aca8961d9ad30 /cmd/podman/version.go
parent962850c6e0dfcee926af31fc0ad24f1f6c26f8ac (diff)
parent25a3923b61a5ca014318e6d957f68abd03947297 (diff)
downloadpodman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.tar.gz
podman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.tar.bz2
podman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.zip
Merge pull request #2274 from baude/cobraprep
Migrate to cobra CLI
Diffstat (limited to 'cmd/podman/version.go')
-rw-r--r--cmd/podman/version.go43
1 files changed, 24 insertions, 19 deletions
diff --git a/cmd/podman/version.go b/cmd/podman/version.go
index ce773ee2e..0e7cd43d5 100644
--- a/cmd/podman/version.go
+++ b/cmd/podman/version.go
@@ -6,20 +6,41 @@ import (
"text/tabwriter"
"time"
+ "github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/formats"
"github.com/containers/libpod/libpod"
"github.com/pkg/errors"
- "github.com/urfave/cli"
+ "github.com/spf13/cobra"
)
+var (
+ versionCommand cliconfig.VersionValues
+ _versionCommand = &cobra.Command{
+ Use: "version",
+ Short: "Display the Podman Version Information",
+ RunE: func(cmd *cobra.Command, args []string) error {
+ versionCommand.InputArgs = args
+ versionCommand.GlobalFlags = MainGlobalOpts
+ return versionCmd(&versionCommand)
+ },
+ }
+)
+
+func init() {
+ versionCommand.Command = _versionCommand
+ flags := versionCommand.Flags()
+ flags.StringVarP(&versionCommand.Format, "format", "f", "", "Change the output format to JSON or a Go template")
+ rootCmd.AddCommand(versionCommand.Command)
+}
+
// versionCmd gets and prints version info for version command
-func versionCmd(c *cli.Context) error {
+func versionCmd(c *cliconfig.VersionValues) error {
output, err := libpod.GetVersion()
if err != nil {
errors.Wrapf(err, "unable to determine version")
}
- versionOutputFormat := c.String("format")
+ versionOutputFormat := c.Format
if versionOutputFormat != "" {
var out formats.Writer
switch versionOutputFormat {
@@ -46,19 +67,3 @@ func versionCmd(c *cli.Context) error {
fmt.Fprintf(w, "OS/Arch:\t%s\n", output.OsArch)
return nil
}
-
-// Cli command to print out the full version of podman
-var (
- versionCommand = cli.Command{
- Name: "version",
- Usage: "Display the Podman Version Information",
- Action: versionCmd,
- Flags: versionFlags,
- }
- versionFlags = []cli.Flag{
- cli.StringFlag{
- Name: "format, f",
- Usage: "Change the output format to JSON or a Go template",
- },
- }
-)