MCPcopy Create free account
hub / github.com/cli/cli / RangeArgs

Function RangeArgs

pkg/cmdutil/args.go:42–54  ·  view source on GitHub ↗

RangeArgs is cobra.RangeArgs with the usage errors ExactArgs gives: more than max arguments is "too many arguments", and fewer than min is msg, so the command can say which argument is missing. Both are flag errors, which print the usage.

(min, max int, msg string)

Source from the content-addressed store, hash-verified

40// the command can say which argument is missing. Both are flag errors, which
41// print the usage.
42func RangeArgs(min, max int, msg string) cobra.PositionalArgs {
43 return func(cmd *cobra.Command, args []string) error {
44 if len(args) > max {
45 return FlagErrorf("too many arguments")
46 }
47
48 if len(args) < min {
49 return FlagErrorf("%s", msg)
50 }
51
52 return nil
53 }
54}
55
56func NoArgsQuoteReminder(cmd *cobra.Command, args []string) error {
57 if len(args) < 1 {

Callers 3

NewCmdViewFunction · 0.92
NewCmdEditFunction · 0.92
TestRangeArgsFunction · 0.85

Calls 1

FlagErrorfFunction · 0.85

Tested by 1

TestRangeArgsFunction · 0.68