summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2020-09-15 14:25:32 -0600
committerEd Santiago <santiago@redhat.com>2020-09-15 15:08:18 -0600
commitdb86ea9bcadd58197db54da7a9b7c3d5e5c52cf8 (patch)
tree2c96b87cef3f8aa40ca44b00de1f2aeca088f517 /cmd/podman
parent2eb3339343482dfa860bd171920ec22fd6a5495d (diff)
downloadpodman-db86ea9bcadd58197db54da7a9b7c3d5e5c52cf8.tar.gz
podman-db86ea9bcadd58197db54da7a9b7c3d5e5c52cf8.tar.bz2
podman-db86ea9bcadd58197db54da7a9b7c3d5e5c52cf8.zip
podman version and --version: fix format, exit
Three unrelated fixes to version output: * podman version --format json: was missing a newline * podman version --format TEMPLATE: had too many newlines * podman --version: would neither display version nor exit if followed by a subcommand ('podman --version ps') The first two were easy: I used my best tweezers to delicately pluck and transfer the misplaced \n and place it where needed. The third was a doozy of a rabbit hole. As best I can tell, a workaround was added in root.go to override cobra's built-in Version handling, apparently to avoid having cobra add "-v" as an alias for "--version". As best I can tell, cobra only does this if the "-v" shortcut is not already taken (at least as of Nov 2019: https://github.com/spf13/cobra/pull/996 ). Also as best I can tell that workaround is purely vestigial, and removing it is safe. I've manually tested "-v" in podman run, system df, and rm. I've run system tests. Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/root.go4
-rw-r--r--cmd/podman/system/version.go5
2 files changed, 1 insertions, 8 deletions
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index d079018a0..8def7112f 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -80,10 +80,6 @@ func init() {
)
rootFlags(rootCmd, registry.PodmanConfig())
-
- // "version" is a local flag to avoid collisions with sub-commands that use "-v"
- var dummyVersion bool
- rootCmd.Flags().BoolVarP(&dummyVersion, "version", "v", false, "Version of Podman")
}
func Execute() {
diff --git a/cmd/podman/system/version.go b/cmd/podman/system/version.go
index edc860d0e..5f39b4820 100644
--- a/cmd/podman/system/version.go
+++ b/cmd/podman/system/version.go
@@ -47,12 +47,9 @@ func version(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- _, err = io.WriteString(os.Stdout, s)
+ _, err = io.WriteString(os.Stdout, s+"\n")
return err
case cmd.Flag("format").Changed:
- if !strings.HasSuffix(versionFormat, "\n") {
- versionFormat += "\n"
- }
out := formats.StdoutTemplate{Output: versions, Template: versionFormat}
err := out.Out()
if err != nil {