Commit 117af86c authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands/cli: Error if there are duplicate values for an option

parent b48b12e4
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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment