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

Function RequiresMinArgs

cli/required.go:34–48  ·  view source on GitHub ↗

RequiresMinArgs returns an error if there is not at least min args

(minArgs int)

Source from the content-addressed store, hash-verified

32
33// RequiresMinArgs returns an error if there is not at least min args
34func RequiresMinArgs(minArgs int) cobra.PositionalArgs {
35 return func(cmd *cobra.Command, args []string) error {
36 if len(args) >= minArgs {
37 return nil
38 }
39 return fmt.Errorf(
40 "%[1]s: '%[2]s' requires at least %[3]d %[4]s\n\nUsage: %[5]s\n\nSee '%[2]s --help' for more information",
41 binName(cmd),
42 cmd.CommandPath(),
43 minArgs,
44 pluralize("argument", minArgs),
45 cmd.UseLine(),
46 )
47 }
48}
49
50// RequiresMaxArgs returns an error if there is not at most max args
51func RequiresMaxArgs(maxArgs int) cobra.PositionalArgs {

Callers 1

TestRequiresMinArgsFunction · 0.85

Calls 2

binNameFunction · 0.85
pluralizeFunction · 0.85

Tested by 1

TestRequiresMinArgsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…