aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/version.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-01-31 13:20:04 -0600
committerbaude <bbaude@redhat.com>2019-02-08 10:26:43 -0600
commit25a3923b61a5ca014318e6d957f68abd03947297 (patch)
tree2ccb4a0bd9bda70c1c258dcb1b8aca8961d9ad30 /cmd/podman/version.go
parent962850c6e0dfcee926af31fc0ad24f1f6c26f8ac (diff)
downloadpodman-25a3923b61a5ca014318e6d957f68abd03947297.tar.gz
podman-25a3923b61a5ca014318e6d957f68abd03947297.tar.bz2
podman-25a3923b61a5ca014318e6d957f68abd03947297.zip
Migrate to cobra CLI
We intend to migrate to the cobra cli from urfave/cli because the project is more well maintained. There are also some technical reasons as well which extend into our remote client work. Signed-off-by: baude <bbaude@redhat.com>
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",
- },
- }
-)