Skip to content

Commit

Permalink
Incorporate better moreThanOne function
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed May 16, 2016
1 parent 4993689 commit 7e71d4b
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions core/commands/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,18 @@ Type: <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
}

Expand Down

0 comments on commit 7e71d4b

Please sign in to comment.