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)
| 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 |
| 13 | func 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 |
| 24 | func NoArgs() cobra.PositionalArgs { |
no test coverage detected