summaryrefslogtreecommitdiff
path: root/cmd/podman/main.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-02-21 15:11:37 -0500
committerGitHub <noreply@github.com>2022-02-21 15:11:37 -0500
commitc9359e1494ef78ede53086cdf762da7f197bb421 (patch)
treea6e81c28b6fa9750a78dcef7e7de6a1c26f3127a /cmd/podman/main.go
parent4ad98b9fd3519ef901430c35d74b1dc7e65f9d84 (diff)
parent44d037898ebc328432823d51ca2da298902a46e9 (diff)
downloadpodman-c9359e1494ef78ede53086cdf762da7f197bb421.tar.gz
podman-c9359e1494ef78ede53086cdf762da7f197bb421.tar.bz2
podman-c9359e1494ef78ede53086cdf762da7f197bb421.zip
Merge pull request #13306 from Luap99/flag-error
provide better error on invalid flag
Diffstat (limited to 'cmd/podman/main.go')
-rw-r--r--cmd/podman/main.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index 9850f5d27..4f8131653 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -72,6 +72,8 @@ func parseCommands() *cobra.Command {
}
parent.AddCommand(c.Command)
+ c.Command.SetFlagErrorFunc(flagErrorFuncfunc)
+
// - templates need to be set here, as PersistentPreRunE() is
// not called when --help is used.
// - rootCmd uses cobra default template not ours
@@ -84,5 +86,11 @@ func parseCommands() *cobra.Command {
os.Exit(1)
}
+ rootCmd.SetFlagErrorFunc(flagErrorFuncfunc)
return rootCmd
}
+
+func flagErrorFuncfunc(c *cobra.Command, e error) error {
+ e = fmt.Errorf("%w\nSee '%s --help'", e, c.CommandPath())
+ return e
+}