Hanlde double args of mixed short and long types

99% of the time if a user wants to pas an argument twice they would do
`-cc` or `--clean --clean`. Still doing `-c --clean` is still a valid
thing to do. This commits allows getArg() to this properly.
This commit is contained in:
morganamilo 2018-04-16 20:22:33 +01:00
parent dccfcb6c69
commit ef5fda0264
No known key found for this signature in database
GPG Key ID: 6FE9E7996B0B082E

View File

@ -217,22 +217,36 @@ func (parser *arguments) existsArg(options ...string) bool {
}
func (parser *arguments) getArg(options ...string) (arg string, double bool, exists bool) {
existCount := 0
for _, option := range options {
arg, exists = parser.options[option]
if exists {
_, double = parser.doubles[option]
return
existCount++
_, exists = parser.doubles[option]
if exists {
existCount++
}
}
arg, exists = parser.globals[option]
if exists {
_, double = parser.doubles[option]
return
existCount++
_, exists = parser.doubles[option]
if exists {
existCount++
}
}
}
double = existCount >= 2
return
}