RangeArgs returns an error if the number of args is not within the expected range.
(min int, max int)
| 102 | |
| 103 | // RangeArgs returns an error if the number of args is not within the expected range. |
| 104 | func RangeArgs(min int, max int) PositionalArgs { |
| 105 | return func(cmd *Command, args []string) error { |
| 106 | if len(args) < min || len(args) > max { |
| 107 | return fmt.Errorf("accepts between %d and %d arg(s), received %d", min, max, len(args)) |
| 108 | } |
| 109 | return nil |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | // MatchAll allows combining several PositionalArgs to work in concert. |
| 114 | func MatchAll(pargs ...PositionalArgs) PositionalArgs { |
no outgoing calls