From 797dee5fd3822251b3c8d3102100765faf813b27 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 17 May 2016 15:47:50 +0200 Subject: [PATCH] Make format logic look much better License: MIT Signed-off-by: Jakub Sztandera --- core/commands/files/files.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/core/commands/files/files.go b/core/commands/files/files.go index a98518589d8d..ecfa3f8893e0 100644 --- a/core/commands/files/files.go +++ b/core/commands/files/files.go @@ -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 = "" + return "", nil + } else if size { + return "", nil + } else if len(format) == 0 { + return format, nil } - if size { - format = "" - } - if len(format) == 0 { - format, _, _ = req.Option("format").String() - } - - return format, nil } func statNode(ds dag.DAGService, fsn mfs.FSNode) (*Object, error) {