MaximumNArgs returns an error if there are more than N args.
(n int)
| 82 | |
| 83 | // MaximumNArgs returns an error if there are more than N args. |
| 84 | func MaximumNArgs(n int) PositionalArgs { |
| 85 | return func(cmd *Command, args []string) error { |
| 86 | if len(args) > n { |
| 87 | return fmt.Errorf("accepts at most %d arg(s), received %d", n, len(args)) |
| 88 | } |
| 89 | return nil |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // ExactArgs returns an error if there are not exactly n args. |
| 94 | func ExactArgs(n int) PositionalArgs { |
no outgoing calls