Browse Source

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.
morganamilo 7 years ago
parent
commit
ef5fda0264
1 changed files with 18 additions and 4 deletions
  1. 18 4
      parser.go

+ 18 - 4
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
 }