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

Incorporate better moreThanOne function

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera
2016-05-16 22:49:23 +02:00
parent 49936895ff
commit 94f1922dc2

View File

@ -127,23 +127,17 @@ Type: <type>`),
Type: Object{},
}
func moreThanOne(a, b, c bool) bool {
return a && b || b && c || a && 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
}