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

Function ExactArgsWithMsg

pkg/validators/cmd.go:13–21  ·  view source on GitHub ↗

ExactArgs is a validator for commands to print an error with a custom message followed by usage, flags and available commands when too few/much arguments are provided

(n int, msg string)

Source from the content-addressed store, hash-verified

11// ExactArgs is a validator for commands to print an error with a custom message
12// followed by usage, flags and available commands when too few/much arguments are provided
13func ExactArgsWithMsg(n int, msg string) cobra.PositionalArgs {
14 return func(cmd *cobra.Command, args []string) error {
15 if len(args) != n {
16 return cmdutil.FlagErrorf("%s", msg)
17 }
18
19 return nil
20 }
21}
22
23// NoArgs is a validator for commands to print an error when an argument is provided
24func NoArgs() cobra.PositionalArgs {

Callers 10

NewGetCmdFunction · 0.92
NewSearchCmdFunction · 0.92
NewDeleteCmdFunction · 0.92
NewGetCmdFunction · 0.92
NewDeleteCmdFunction · 0.92
NewListCmdFunction · 0.92
NewUpsertCmdFunction · 0.92
NewUpsertCmdFunction · 0.92
NoArgsFunction · 0.85
ExactArgsFunction · 0.85

Calls 1

FlagErrorfFunction · 0.92

Tested by

no test coverage detected