mirror of
https://github.com/spf13/cobra
synced 2025-05-05 04:47:22 +00:00
Update args.go
This commit is contained in:
parent
e1b831e5c2
commit
b10da1fee5
1 changed files with 10 additions and 0 deletions
10
args.go
10
args.go
|
@ -66,6 +66,16 @@ func MinimumNArgs(n int) PositionalArgs {
|
|||
}
|
||||
}
|
||||
|
||||
// MinimumNArgsCustomError returns an error if there is not at least N args.
|
||||
func MinimumNArgsCustomError(n int,custom string) PositionalArgs {
|
||||
return func(cmd *Command, args []string) error {
|
||||
if len(args) < n {
|
||||
return fmt.Errorf("requires at least %d arg(s), only received %d,%s", n, len(args),custom)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// MaximumNArgs returns an error if there are more than N args.
|
||||
func MaximumNArgs(n int) PositionalArgs {
|
||||
return func(cmd *Command, args []string) error {
|
||||
|
|
Loading…
Add table
Reference in a new issue