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

Function NoArgs

cli/required.go:10–31  ·  view source on GitHub ↗

NoArgs validates args and returns an error if there are any args

(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

8
9// NoArgs validates args and returns an error if there are any args
10func NoArgs(cmd *cobra.Command, args []string) error {
11 if len(args) == 0 {
12 return nil
13 }
14
15 if cmd.HasSubCommands() {
16 return fmt.Errorf(
17 "%[1]s: unknown command: %[2]s %[3]s\n\nUsage: %[4]s\n\nRun '%[2]s --help' for more information",
18 binName(cmd),
19 cmd.CommandPath(),
20 args[0],
21 cmd.UseLine(),
22 )
23 }
24
25 return fmt.Errorf(
26 "%[1]s: '%[2]s' accepts no arguments\n\nUsage: %[3]s\n\nRun '%[2]s --help' for more information",
27 binName(cmd),
28 cmd.CommandPath(),
29 cmd.UseLine(),
30 )
31}
32
33// RequiresMinArgs returns an error if there is not at least min args
34func RequiresMinArgs(minArgs int) cobra.PositionalArgs {

Callers

nothing calls this directly

Calls 1

binNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…