@cryptotaxi247 / kubo / commits / 94f1922dc

Incorporate better moreThanOne function

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed May 16, 2016 at 22:49 UTC 94f1922dc27d66ace5ae80f6674ac92d49d506d2
1 file changed +5 -11
core/commands/files/files.go
+5 -11
@@ -127,23 +127,17 @@ Type: <type>`),
127 Type: Object{},
128 }
129
130 +func moreThanOne(a, b, c bool) bool {
131 + return a && b || b && c || a && c
132 +}
133 +
134 func statGetFormatOptions(req cmds.Request) (string, error) {
135
136 hash, _, _ := req.Option("hash").Bool()
137 size, _, _ := req.Option("size").Bool()
138 formatSpecified := req.Option("format").Found()
139
136 - count := 0
137 - if hash {
138 - count++
139 - }
140 - if size {
141 - count++
142 - }
143 - if formatSpecified {
144 - count++
145 - }
146 - if count > 1 {
140 + if moreThanOne(hash, size, formatSpecified) {
141 return "", formatError
142 }
143