summaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/cobra/args.go
diff options
context:
space:
mode:
authordependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>2020-09-25 08:16:44 +0000
committerDaniel J Walsh <dwalsh@redhat.com>2020-09-25 04:19:55 -0400
commit017f8d6a632d26757685a5e629e3263db14b5156 (patch)
tree6cdd71e21d59a6a2814c1927376a370f2bd77e18 /vendor/github.com/spf13/cobra/args.go
parent90c2cc6c8342e96ca0a21e59c3cdb7761b2229ea (diff)
downloadpodman-017f8d6a632d26757685a5e629e3263db14b5156.tar.gz
podman-017f8d6a632d26757685a5e629e3263db14b5156.tar.bz2
podman-017f8d6a632d26757685a5e629e3263db14b5156.zip
Bump github.com/containers/common from 0.22.0 to 0.23.0
Bumps [github.com/containers/common](https://github.com/containers/common) from 0.22.0 to 0.23.0. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.22.0...v0.23.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/spf13/cobra/args.go')
-rw-r--r--vendor/github.com/spf13/cobra/args.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/vendor/github.com/spf13/cobra/args.go b/vendor/github.com/spf13/cobra/args.go
index c4d820b85..70e9b2629 100644
--- a/vendor/github.com/spf13/cobra/args.go
+++ b/vendor/github.com/spf13/cobra/args.go
@@ -2,6 +2,7 @@ package cobra
import (
"fmt"
+ "strings"
)
type PositionalArgs func(cmd *Command, args []string) error
@@ -34,8 +35,15 @@ func NoArgs(cmd *Command, args []string) error {
// OnlyValidArgs returns an error if any args are not in the list of ValidArgs.
func OnlyValidArgs(cmd *Command, args []string) error {
if len(cmd.ValidArgs) > 0 {
+ // Remove any description that may be included in ValidArgs.
+ // A description is following a tab character.
+ var validArgs []string
+ for _, v := range cmd.ValidArgs {
+ validArgs = append(validArgs, strings.Split(v, "\t")[0])
+ }
+
for _, v := range args {
- if !stringInSlice(v, cmd.ValidArgs) {
+ if !stringInSlice(v, validArgs) {
return fmt.Errorf("invalid argument %q for %q%s", v, cmd.CommandPath(), cmd.findSuggestions(args[0]))
}
}