diff options
author | Valentin Rothberg <vrothberg@suse.com> | 2018-08-31 09:24:49 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-31 10:19:11 +0000 |
commit | bbcad6f572207779ead07127e6619961bc0758b9 (patch) | |
tree | 38cc4978041a3c39862daa1d916efa9e3108420e /cmd/podman/common.go | |
parent | 3839c00ae2f132b115ffabec500ddba2a536527e (diff) | |
download | podman-bbcad6f572207779ead07127e6619961bc0758b9.tar.gz podman-bbcad6f572207779ead07127e6619961bc0758b9.tar.bz2 podman-bbcad6f572207779ead07127e6619961bc0758b9.zip |
catch command-not-found errors
Add a special handler to catch errors caused by specifying unknown
commands to Podman. This allows printing a more helpful error message.
```
$ podman
Command "123123" not found.
See `podman --help`.
$ podman pod 123123
Command "123123" not found.
See `podman pod --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.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 3d0f1159f..93b16f4e3 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -51,6 +51,10 @@ func usageErrorHandler(context *cli.Context, err error, _ bool) error { return fmt.Errorf("%s\nSee '%s --help'.", err, cmd) } +func commandNotFoundHandler(context *cli.Context, command string) { + fmt.Fprintf(context.App.Writer, "Command %q not found.\nSee `%s --help`.\n", command, context.App.Name) +} + // 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. |