cmd/utils: make mutually exclusive flag error prettier

It now reads:

   Fatal: flags --dev, --testnet can't be used at the same time
This commit is contained in:
Felix Lange 2017-04-11 13:30:23 +02:00
parent 766ce7abca
commit 08c62b128a

View file

@ -778,14 +778,14 @@ func setEthash(ctx *cli.Context, cfg *eth.Config) {
} }
func checkExclusive(ctx *cli.Context, flags ...cli.BoolFlag) { func checkExclusive(ctx *cli.Context, flags ...cli.BoolFlag) {
set := 0 set := make([]string, 0, 1)
for _, flag := range flags { for _, flag := range flags {
if ctx.GlobalIsSet(flag.Name) { if ctx.GlobalIsSet(flag.Name) {
set++ set = append(set, "--"+flag.Name)
} }
} }
if set > 1 { if len(set) > 1 {
Fatalf("The %v flags are mutually exclusive", flags) Fatalf("flags %v can't be used at the same time", strings.Join(set, ", "))
} }
} }