diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2018-12-06 03:20:16 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2018-12-06 03:20:16 -0500 |
commit | 40678b119c0186bf7c56dc09d131e697c55cb9fd (patch) | |
tree | dfb1cc13b0bdc1abad1ada51970bf0ac03d46810 /cmd/podman/version.go | |
parent | dcb68d1aa24b2dd00d793f5a66f96cc5403b43c3 (diff) | |
parent | 75b19ca8abe1957f3c48035767960a6b20c10519 (diff) | |
download | podman-40678b119c0186bf7c56dc09d131e697c55cb9fd.tar.gz podman-40678b119c0186bf7c56dc09d131e697c55cb9fd.tar.bz2 podman-40678b119c0186bf7c56dc09d131e697c55cb9fd.zip |
Merge branch 'master' of github.com:containers/libpod into vendor
Diffstat (limited to 'cmd/podman/version.go')
-rw-r--r-- | cmd/podman/version.go | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/cmd/podman/version.go b/cmd/podman/version.go index f896229c4..d81deb696 100644 --- a/cmd/podman/version.go +++ b/cmd/podman/version.go @@ -4,6 +4,7 @@ import ( "fmt" "time" + "github.com/containers/libpod/cmd/podman/formats" "github.com/containers/libpod/libpod" "github.com/pkg/errors" "github.com/urfave/cli" @@ -15,13 +16,26 @@ func versionCmd(c *cli.Context) error { if err != nil { errors.Wrapf(err, "unable to determine version") } + + versionOutputFormat := c.String("format") + if versionOutputFormat != "" { + var out formats.Writer + switch versionOutputFormat { + case formats.JSONString: + out = formats.JSONStruct{Output: output} + default: + out = formats.StdoutTemplate{Output: output, Template: versionOutputFormat} + } + formats.Writer(out).Out() + return nil + } fmt.Println("Version: ", output.Version) fmt.Println("Go Version: ", output.GoVersion) if output.GitCommit != "" { fmt.Println("Git Commit: ", output.GitCommit) } // Prints out the build time in readable format - if libpod.BuildInfo != "" { + if output.Built != 0 { fmt.Println("Built: ", time.Unix(output.Built, 0).Format(time.ANSIC)) } @@ -30,8 +44,17 @@ func versionCmd(c *cli.Context) error { } // Cli command to print out the full version of podman -var versionCommand = cli.Command{ - Name: "version", - Usage: "Display the PODMAN Version Information", - Action: versionCmd, -} +var ( + versionCommand = cli.Command{ + Name: "version", + Usage: "Display the Podman Version Information", + Action: versionCmd, + Flags: versionFlags, + } + versionFlags = []cli.Flag{ + cli.StringFlag{ + Name: "format", + Usage: "Change the output format to JSON or a Go template", + }, + } +) |