mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
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:
parent
dccfcb6c69
commit
ef5fda0264
22
parser.go
22
parser.go
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user