Skip to content

Commit

Permalink
Make format logic look much better
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 17, 2016
1 parent 94f1922 commit 797dee5
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions core/commands/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,19 @@ func statGetFormatOptions(req cmds.Request) (string, error) {

hash, _, _ := req.Option("hash").Bool()
size, _, _ := req.Option("size").Bool()
formatSpecified := req.Option("format").Found()
format, found, _ := req.Option("format").String()

if moreThanOne(hash, size, formatSpecified) {
if moreThanOne(hash, size, found) {
return "", formatError
}

format := ""
if hash {
format = "<hash>"
return "<hash>", nil
} else if size {
return "<cumulsize>", nil
} else if len(format) == 0 {
return format, nil
}
if size {
format = "<cumulsize>"
}
if len(format) == 0 {
format, _, _ = req.Option("format").String()
}

return format, nil
}

func statNode(ds dag.DAGService, fsn mfs.FSNode) (*Object, error) {
Expand Down

0 comments on commit 797dee5

Please sign in to comment.