MCPcopy Index your code
hub / github.com/docker/cli / RequiresRangeArgs

Function RequiresRangeArgs

cli/required.go:68–83  ·  view source on GitHub ↗

RequiresRangeArgs returns an error if there is not at least min args and at most max args

(minArgs int, maxArgs int)

Source from the content-addressed store, hash-verified

66
67// RequiresRangeArgs returns an error if there is not at least min args and at most max args
68func RequiresRangeArgs(minArgs int, maxArgs int) cobra.PositionalArgs {
69 return func(cmd *cobra.Command, args []string) error {
70 if len(args) >= minArgs && len(args) <= maxArgs {
71 return nil
72 }
73 return fmt.Errorf(
74 "%[1]s: '%[2]s' requires at least %[3]d and at most %[4]d %[5]s\n\nUsage: %[6]s\n\nRun '%[2]s --help' for more information",
75 binName(cmd),
76 cmd.CommandPath(),
77 minArgs,
78 maxArgs,
79 pluralize("argument", maxArgs),
80 cmd.UseLine(),
81 )
82 }
83}
84
85// ExactArgs returns an error if there is not the exact number of args
86func ExactArgs(number int) cobra.PositionalArgs {

Callers 1

TestRequiresRangeArgsFunction · 0.85

Calls 2

binNameFunction · 0.85
pluralizeFunction · 0.85

Tested by 1

TestRequiresRangeArgsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…