MCPcopy
hub / github.com/spf13/cobra / legacyArgs

Function legacyArgs

args.go:28–39  ·  view source on GitHub ↗

legacyArgs validation has the following behaviour: - root commands with no subcommands can take arbitrary arguments - root commands with subcommands will do subcommand validity checking - subcommands will always accept arbitrary arguments

(cmd *Command, args []string)

Source from the content-addressed store, hash-verified

26// - root commands with subcommands will do subcommand validity checking
27// - subcommands will always accept arbitrary arguments
28func legacyArgs(cmd *Command, args []string) error {
29 // no subcommand, always take args
30 if !cmd.HasSubCommands() {
31 return nil
32 }
33
34 // root command with subcommands, do subcommand checking.
35 if !cmd.HasParent() && len(args) > 0 {
36 return fmt.Errorf("unknown command %q for %q%s", args[0], cmd.CommandPath(), cmd.findSuggestions(args[0]))
37 }
38 return nil
39}
40
41// NoArgs returns an error if any args are included.
42func NoArgs(cmd *Command, args []string) error {

Callers 1

FindMethod · 0.85

Calls 4

HasSubCommandsMethod · 0.80
HasParentMethod · 0.80
CommandPathMethod · 0.80
findSuggestionsMethod · 0.80

Tested by

no test coverage detected