MCPcopy
hub / github.com/spf13/cobra / RangeArgs

Function RangeArgs

args.go:104–111  ·  view source on GitHub ↗

RangeArgs returns an error if the number of args is not within the expected range.

(min int, max int)

Source from the content-addressed store, hash-verified

102
103// RangeArgs returns an error if the number of args is not within the expected range.
104func 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.
114func MatchAll(pargs ...PositionalArgs) PositionalArgs {

Calls

no outgoing calls