func (parsed *SubCommandArgs) ParseFlag(opt *SubOptions) (value bool, retval int, err string) {
	la := len(parsed.args)

	// check if the flag has been set
	// and if so remove the flag from the rest of the args
	if la > 0 && parsed.args[0] == opt.Flag {
		value = true
		parsed.args = parsed.args[1:]
	}

	// if we have exactly zero arguments, the flag is mandatory or to be omitted
	if opt.MinArgs == 0 && opt.MaxArgs == 0 {

		// when we got extra arguments, or we got an invalid flag value
		// show a dedicated error message
		if la > 1 || (la == 1 && !value) {
			err = fmt.Sprintf(constants.StringUnknownArgument, parsed.Command, opt.Flag)
			retval = constants.ErrorSpecificParseArgs
			return
		}

	}

	// and return
	return
}
// ParseFlag parses a single flag
ParseFlag parses a single flag
// ParseFlag parses a single flag
func (parsed *SubCommandArgs) ParseFlag(opt *SubOptions) (value bool, retval int, err string) {
	la := len(parsed.args)
	if la > 0 && parsed.args[0] == opt.Flag {
		value = true
		parsed.args = parsed.args[1:]
	}
	if opt.MinArgs == 0 && opt.MaxArgs == 0 {
		if la > 1 || (la == 1 && !value) {
			err = fmt.Sprintf(constants.StringUnknownArgument, parsed.Command, opt.Flag)
			retval = constants.ErrorSpecificParseArgs
			return
		}
	}
	return
}
func ( parsed * SubCommandArgs ) ParseFlag ( opt * SubOptions ) ( value bool , retval int , err string ) { la := len ( parsed . args ) if la > 0 && parsed . args [ 0 ] == opt . Flag { value = true parsed . args = parsed . args [ 1 : ] } if opt . MinArgs == 0 && opt . MaxArgs == 0 { if la > 1 || ( la == 1 && ! value ) { err = fmt . Sprintf ( constants . StringUnknownArgument , parsed . Command , opt . Flag ) retval = constants . ErrorSpecificParseArgs return } } return }
ParseFlag parses a single flag
ParseFlag parses a single flag
// check if the flag has been set // and if so remove the flag from the rest of the args // if we have exactly zero arguments, the flag is mandatory or to be omitted // when we got extra arguments, or we got an invalid flag value // show a dedicated error message // and return