From 7e71d4b375c258b47b8723c9a62e8c826ac42560 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 16 May 2016 22:49:23 +0200 Subject: [PATCH] Incorporate better moreThanOne function License: MIT Signed-off-by: Jakub Sztandera --- core/commands/files/files.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/core/commands/files/files.go b/core/commands/files/files.go index e1fb560c6a48..13112b77470b 100644 --- a/core/commands/files/files.go +++ b/core/commands/files/files.go @@ -127,23 +127,18 @@ Type: `), Type: Object{}, } +// General utility function returning true if more than one boolean +func moreThanOne(a, b, c bool) bool { + return !((a == b == c) && !(a && b && c)) && (a || b || c) +} + func statGetFormatOptions(req cmds.Request) (string, error) { hash, _, _ := req.Option("hash").Bool() size, _, _ := req.Option("size").Bool() formatSpecified := req.Option("format").Found() - count := 0 - if hash { - count++ - } - if size { - count++ - } - if formatSpecified { - count++ - } - if count > 1 { + if moreThanOne(hash, size, formatSpecified) { return "", formatError }