summaryrefslogtreecommitdiff
path: root/cmd/podman/common.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-08 04:20:14 -0800
committerGitHub <noreply@github.com>2019-03-08 04:20:14 -0800
commit9e2cd7fea1c03e36c9354c8f67a4f08721fdc503 (patch)
tree6eebe6a421f80b782f9c20f910deca62abc83660 /cmd/podman/common.go
parent8a21e231e63e557448f3471ff57a27fac682d9cc (diff)
parent181f327d57ab84918572b69d2a039c43a8d7b871 (diff)
downloadpodman-9e2cd7fea1c03e36c9354c8f67a4f08721fdc503.tar.gz
podman-9e2cd7fea1c03e36c9354c8f67a4f08721fdc503.tar.bz2
podman-9e2cd7fea1c03e36c9354c8f67a4f08721fdc503.zip
Merge pull request #2580 from rhatdan/cleanup1
More cleanup for failures on missing commands.
Diffstat (limited to 'cmd/podman/common.go')
-rw-r--r--cmd/podman/common.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 9cd1998c8..1de0c7187 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
- "github.com/spf13/cobra"
"os"
"strings"
@@ -14,6 +13,7 @@ import (
"github.com/containers/storage"
"github.com/fatih/camelcase"
"github.com/pkg/errors"
+ "github.com/spf13/cobra"
)
var (
@@ -67,6 +67,16 @@ func noSubArgs(c *cobra.Command, args []string) error {
return nil
}
+func commandRunE() func(*cobra.Command, []string) error {
+ return func(cmd *cobra.Command, args []string) error {
+ if len(args) > 0 {
+ return errors.Errorf("unrecognized command `%s %s`\nTry '%s --help' for more information.", cmd.CommandPath(), args[0], cmd.CommandPath())
+ } else {
+ return errors.Errorf("missing command '%s COMMAND'\nTry '%s --help' for more information.", cmd.CommandPath(), cmd.CommandPath())
+ }
+ }
+}
+
// getAllOrLatestContainers tries to return the correct list of containers
// depending if --all, --latest or <container-id> is used.
// It requires the Context (c) and the Runtime (runtime). As different
@@ -537,7 +547,7 @@ Description:
// This blocks the desplaying of the global options. The main podman
// command should not use this.
func UsageTemplate() string {
- return `Usage:{{if .Runnable}}
+ return `Usage:{{if (and .Runnable (not .HasAvailableSubCommands))}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}