From 117af86ca73d624be7d389ffec5ef606c16fca4d Mon Sep 17 00:00:00 2001 From: Matt Bell <mappum@gmail.com> Date: Fri, 17 Oct 2014 18:23:11 -0700 Subject: [PATCH] commands/cli: Error if there are duplicate values for an option --- commands/cli/parse.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commands/cli/parse.go b/commands/cli/parse.go index 10c4bbfc..8651aa65 100644 --- a/commands/cli/parse.go +++ b/commands/cli/parse.go @@ -1,6 +1,7 @@ package cli import ( + "fmt" "strings" "github.com/jbenet/go-ipfs/commands" @@ -47,8 +48,6 @@ func parseOptions(input []string) (map[string]interface{}, []string, error) { opts := make(map[string]interface{}) args := make([]string, 0) - // TODO: error if one option is defined multiple times - for i := 0; i < len(input); i++ { blob := input[i] @@ -67,6 +66,10 @@ func parseOptions(input []string) (map[string]interface{}, []string, error) { value = split[1] } + if _, ok := opts[name]; ok { + return nil, nil, fmt.Errorf("Duplicate values for option '%s'", name) + } + opts[name] = value } else { -- GitLab