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

Function ExactArgs

cli/required.go:86–100  ·  view source on GitHub ↗

ExactArgs returns an error if there is not the exact number of args

(number int)

Source from the content-addressed store, hash-verified

84
85// ExactArgs returns an error if there is not the exact number of args
86func ExactArgs(number int) cobra.PositionalArgs {
87 return func(cmd *cobra.Command, args []string) error {
88 if len(args) == number {
89 return nil
90 }
91 return fmt.Errorf(
92 "%[1]s: '%[2]s' requires %[3]d %[4]s\n\nUsage: %[5]s\n\nRun '%[2]s --help' for more information",
93 binName(cmd),
94 cmd.CommandPath(),
95 number,
96 pluralize("argument", number),
97 cmd.UseLine(),
98 )
99 }
100}
101
102// binName returns the name of the binary / root command (usually 'docker').
103func binName(cmd *cobra.Command) string {

Callers 1

TestExactArgsFunction · 0.85

Calls 2

binNameFunction · 0.85
pluralizeFunction · 0.85

Tested by 1

TestExactArgsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…