提交 117af86c 作者: Matt Bell 提交者: Juan Batiz-Benet

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

上级 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 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论