summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-06-24 11:58:10 -0400
committerGitHub <noreply@github.com>2021-06-24 11:58:10 -0400
commitd1f57a07c24a0defc0b0027206fc4454307f64fa (patch)
treea417d16ec7c64d4599b9d8c13b5615a9f1f6c943 /cmd/podman
parent21d80faa0b30a042b62566a2ffdff5510a92b9e6 (diff)
parentee7a9d736bd1c34474266cb99c244d399fd12ab9 (diff)
downloadpodman-d1f57a07c24a0defc0b0027206fc4454307f64fa.tar.gz
podman-d1f57a07c24a0defc0b0027206fc4454307f64fa.tar.bz2
podman-d1f57a07c24a0defc0b0027206fc4454307f64fa.zip
Merge pull request #10771 from infiniteregrets/cli
[NO TESTS NEEDED] Suggestions for typos/ incorrect commands for Podman CLI
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/validate/args.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/cmd/podman/validate/args.go b/cmd/podman/validate/args.go
index c00813369..fc07a6acc 100644
--- a/cmd/podman/validate/args.go
+++ b/cmd/podman/validate/args.go
@@ -3,6 +3,7 @@ package validate
import (
"fmt"
"strconv"
+ "strings"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/pkg/errors"
@@ -20,7 +21,11 @@ func NoArgs(cmd *cobra.Command, args []string) error {
// SubCommandExists returns an error if no sub command is provided
func SubCommandExists(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
- return errors.Errorf("unrecognized command `%[1]s %[2]s`\nTry '%[1]s --help' for more information.", cmd.CommandPath(), args[0])
+ suggestions := cmd.SuggestionsFor(args[0])
+ if len(suggestions) == 0 {
+ return errors.Errorf("unrecognized command `%[1]s %[2]s`\nTry '%[1]s --help' for more information.", cmd.CommandPath(), args[0])
+ }
+ return errors.Errorf("unrecognized command `%[1]s %[2]s`\n\nDid you mean this?\n\t%[3]s\n\nTry '%[1]s --help' for more information.", cmd.CommandPath(), args[0], strings.Join(suggestions, "\n\t"))
}
return errors.Errorf("missing command '%[1]s COMMAND'\nTry '%[1]s --help' for more information.", cmd.CommandPath())
}