1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 03:19:47 +08:00

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

This commit is contained in:
Matt Bell
2014-10-17 18:23:11 -07:00
committed by Juan Batiz-Benet
parent b48b12e425
commit 117af86ca7

View File

@ -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 {