From 09c462d735082efa0489b66c66f0590460f4f00c Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 16 Jun 2022 16:20:30 +0200 Subject: fix "podman -h" help output `podman -h` currently returns an error: `Error: pflag: help requested` This bug was introduced in 44d037898ebc, the problem is that we wrap the error and cobra lib checks with `==` for this one and not errors.Is(). I have a PR upstream to fix this but for now this also works. Signed-off-by: Paul Holzinger --- cmd/podman/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cmd') 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 } -- cgit v1.2.3-54-g00ecf