MCPcopy Create free account
hub / github.com/algolia/cli / ExactArgs

Function ExactArgs

pkg/validators/cmd.go:37–52  ·  view source on GitHub ↗

ExactArgs is the same as ExactArgsWithMsg but displays a default error message

(n int)

Source from the content-addressed store, hash-verified

35// ExactArgs is the same as ExactArgsWithMsg but displays
36// a default error message
37func ExactArgs(n int) cobra.PositionalArgs {
38 argument := "argument"
39 if n > 1 {
40 argument = argument + "s"
41 }
42
43 return func(cmd *cobra.Command, args []string) error {
44 extractArgs := ExactArgsWithMsg(n, fmt.Sprintf("`%s` requires exactly %d %s.",
45 cmd.CommandPath(),
46 n,
47 argument,
48 ))
49
50 return extractArgs(cmd, args)
51 }
52}
53
54// AtLeastNArgs is a validator for commands to print an error with a custom message
55// followed by usage, flags and available commands when too few argument(s) are provided

Callers 15

NewImportCmdFunction · 0.92
NewDeleteCmdFunction · 0.92
NewBrowseCmdFunction · 0.92
NewUpdateCmdFunction · 0.92
NewRemoveCmdFunction · 0.92
NewSetDefaultCmdFunction · 0.92
NewSearchCmdFunction · 0.92
NewImportCmdFunction · 0.92
NewDeleteCmdFunction · 0.92
NewSaveCmdFunction · 0.92
NewBrowseCmdFunction · 0.92
NewGetCmdFunction · 0.92

Calls 1

ExactArgsWithMsgFunction · 0.85

Tested by

no test coverage detected