commands/cli: Error if there are duplicate values for an option
Matt Bell committed
Oct 17, 2014 at 18:23 UTC
117af86ca73d624be7d389ffec5ef606c16fca4d
1 file changed
+5
-2
commands/cli/parse.go
+5
-2
@@ -1,6 +1,7 @@
1
package cli
2
3
import (
4
+ "fmt"
5
"strings"
6
7
"github.com/jbenet/go-ipfs/commands"
@@ -47,8 +48,6 @@ func parseOptions(input []string) (map[string]interface{}, []string, error) {
48
opts := make(map[string]interface{})
49
args := make([]string, 0)
50
50
- // TODO: error if one option is defined multiple times
51
-
51
for i := 0; i < len(input); i++ {
52
blob := input[i]
53
@@ -67,6 +66,10 @@ func parseOptions(input []string) (map[string]interface{}, []string, error) {
66
value = split[1]
67
}
68
69
+ if _, ok := opts[name]; ok {
70
+ return nil, nil, fmt.Errorf("Duplicate values for option '%s'", name)
71
+ }
72
+
73
opts[name] = value
74
75
} else {