summaryrefslogtreecommitdiff
path: root/cmd/podman/common.go
diff options
context:
space:
mode:
authorValentin Rothberg <vrothberg@suse.com>2018-08-30 19:31:05 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-31 10:19:11 +0000
commit3839c00ae2f132b115ffabec500ddba2a536527e (patch)
tree93e57296f79378d949546c8354d6dd2f5a207b5a /cmd/podman/common.go
parent82a6b373a59b82532263b19c0a8abff9af4a96db (diff)
downloadpodman-3839c00ae2f132b115ffabec500ddba2a536527e.tar.gz
podman-3839c00ae2f132b115ffabec500ddba2a536527e.tar.bz2
podman-3839c00ae2f132b115ffabec500ddba2a536527e.zip
don't print help message for usage errors
Don't print potentially verbose help messages in case of usage errors, but print only the usage error followed by a pointer to the command's help. This aligns with Docker. ``` $ podman run -h flag needs an argument: -h See 'podman run --help'. ``` Signed-off-by: Valentin Rothberg <vrothberg@suse.com> Closes: #1379 Approved by: rhatdan
Diffstat (limited to 'cmd/podman/common.go')
-rw-r--r--cmd/podman/common.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 4ddfd5e0a..3d0f1159f 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -2,6 +2,7 @@ package main
import (
"context"
+ "fmt"
"reflect"
"regexp"
"strings"
@@ -42,6 +43,14 @@ func shortID(id string) string {
return id
}
+func usageErrorHandler(context *cli.Context, err error, _ bool) error {
+ cmd := context.App.Name
+ if len(context.Command.Name) > 0 {
+ cmd = cmd + " " + context.Command.Name
+ }
+ return fmt.Errorf("%s\nSee '%s --help'.", err, cmd)
+}
+
// validateFlags searches for StringFlags or StringSlice flags that never had
// a value set. This commonly occurs when the CLI mistakenly takes the next
// option and uses it as a value.