func (parsed *SubCommandArgs) EnsureArguments(min int, max int) (argc int, argv []string, retval int, err string) {
	argc = len(parsed.args)

	// if we are outside of the range
	if argc < min || ((max != -1) && (argc > max)) {
		// reset argc and argv
		argc = 0

		// error is specific
		retval = constants.ErrorSpecificParseArgs

		// if we have min == max we take an exact number of arguments
		if min == max {
			if min != 0 {
				err = fmt.Sprintf(constants.StringTakesExactlyArguments, parsed.Command, min)

				// special case: no arguments
			} else {
				err = fmt.Sprintf(constants.StringTakesNoArguments, parsed.Command)
			}

			// special case: maximal number of arguments == -1 => unlimited number of arguments allowed
		} else if max == -1 {
			err = fmt.Sprintf(constants.StringTakesMinArguments, parsed.Command, min)

			// if we do not, we have a range
		} else {
			err = fmt.Sprintf(constants.StringTakesBetweenArguments, parsed.Command, min, max)
		}

		return
	}

	// return the arguments too
	argv = parsed.args
	return
}
// EnsureArguments ensures that between min and max (both inclusive) arguments are given
EnsureArguments ensures that between min and max (both inclusive) arguments are given
// EnsureArguments ensures that between min and max ( both inclusive ) arguments are given
func (parsed *SubCommandArgs) EnsureArguments(min int, max int) (argc int, argv []string, retval int, err string) {
	argc = len(parsed.args)
	if argc < min || ((max != -1) && (argc > max)) {
		argc = 0
		retval = constants.ErrorSpecificParseArgs
		if min == max {
			if min != 0 {
				err = fmt.Sprintf(constants.StringTakesExactlyArguments, parsed.Command, min)
			} else {
				err = fmt.Sprintf(constants.StringTakesNoArguments, parsed.Command)
			}
		} else if max == -1 {
			err = fmt.Sprintf(constants.StringTakesMinArguments, parsed.Command, min)
		} else {
			err = fmt.Sprintf(constants.StringTakesBetweenArguments, parsed.Command, min, max)
		}
		return
	}
	argv = parsed.args
	return
}
func ( parsed * SubCommandArgs ) EnsureArguments ( min int , max int ) ( argc int , argv [ ] string , retval int , err string ) { argc = len ( parsed . args ) if argc < min || ( ( max != - 1 ) && ( argc > max ) ) { argc = 0 retval = constants . ErrorSpecificParseArgs if min == max { if min != 0 { err = fmt . Sprintf ( constants . StringTakesExactlyArguments , parsed . Command , min ) } else { err = fmt . Sprintf ( constants . StringTakesNoArguments , parsed . Command ) } } else if max == - 1 { err = fmt . Sprintf ( constants . StringTakesMinArguments , parsed . Command , min ) } else { err = fmt . Sprintf ( constants . StringTakesBetweenArguments , parsed . Command , min , max ) } return } argv = parsed . args return }
EnsureArguments ensures that between min and max (both inclusive) arguments are given
EnsureArguments ensures that between min and max ( both inclusive ) arguments are given
// if we are outside of the range // reset argc and argv // error is specific // if we have min == max we take an exact number of arguments // special case: no arguments // special case: maximal number of arguments == -1 => unlimited number of arguments allowed // if we do not, we have a range // return the arguments too