final checks on opt values moved after option parsing is complete
This commit is contained in:
@@ -104,16 +104,12 @@ func (cli *CliParser) parseArg(arg string, index int) (skipNextArg bool, err err
|
||||
}
|
||||
for i, optName := range opts {
|
||||
if opt := cli.findOptionByArg(dashes + optName); opt != nil {
|
||||
var optValue string
|
||||
if equalPresent && i == len(opts)-1 {
|
||||
_, optValue, err = opt.parse(cli, index, &value)
|
||||
_, _, err = opt.parse(cli, index, &value)
|
||||
} else if i < len(opts)-1 && opt.requiresValue() {
|
||||
err = errMissingOptionValue(dashes + optName)
|
||||
} else {
|
||||
skipNextArg, optValue, err = opt.parse(cli, index, nil)
|
||||
}
|
||||
if err == nil && i == len(opts)-1 {
|
||||
err = opt.finalCheck(optValue)
|
||||
skipNextArg, _, err = opt.parse(cli, index, nil)
|
||||
}
|
||||
} else {
|
||||
err = errUnknownOption(dashes + optName)
|
||||
|
||||
Reference in New Issue
Block a user