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)
| 40 | // the command can say which argument is missing. Both are flag errors, which |
| 41 | // print the usage. |
| 42 | func 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 | |
| 56 | func NoArgsQuoteReminder(cmd *cobra.Command, args []string) error { |
| 57 | if len(args) < 1 { |