aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoropenshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com>2022-06-16 18:06:29 +0000
committerGitHub <noreply@github.com>2022-06-16 18:06:29 +0000
commit5cba4dc2e490b5c652ba0821067b63d7b2e4cf8f (patch)
tree5f39931a2eb7821f992ae849a7ab5f57607a2784
parent8765adb756c570a13f06b9c60596d34567d6568b (diff)
parent09c462d735082efa0489b66c66f0590460f4f00c (diff)
downloadpodman-5cba4dc2e490b5c652ba0821067b63d7b2e4cf8f.tar.gz
podman-5cba4dc2e490b5c652ba0821067b63d7b2e4cf8f.tar.bz2
podman-5cba4dc2e490b5c652ba0821067b63d7b2e4cf8f.zip
Merge pull request #14619 from Luap99/help
fix "podman -h" help output
-rw-r--r--cmd/podman/main.go9
-rw-r--r--test/system/015-help.bats2
2 files changed, 10 insertions, 1 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index 929c8a757..c6ba69e94 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "errors"
"fmt"
"os"
@@ -26,6 +27,7 @@ import (
"github.com/containers/storage/pkg/reexec"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
func main() {
@@ -101,6 +103,13 @@ func parseCommands() *cobra.Command {
}
func flagErrorFuncfunc(c *cobra.Command, e error) error {
+ // cobra compares via == and not errors.Is so we cannot wrap that error.
+ // This is required to make podman -h work.
+ // This can be removed once https://github.com/spf13/cobra/pull/1730
+ // is merged and vendored into podman.
+ if errors.Is(e, pflag.ErrHelp) {
+ return e
+ }
e = fmt.Errorf("%w\nSee '%s --help'", e, c.CommandPath())
return e
}
diff --git a/test/system/015-help.bats b/test/system/015-help.bats
index 1356c99a0..dd5a7ed44 100644
--- a/test/system/015-help.bats
+++ b/test/system/015-help.bats
@@ -199,7 +199,7 @@ function check_help() {
check_help
# Test for regression of #7273 (spurious "--remote" help on output)
- for helpopt in help --help; do
+ for helpopt in help --help -h; do
run_podman $helpopt
is "${lines[0]}" "Manage pods, containers and images" \
"podman $helpopt: first line of output"