@cryptotaxi247 / kubo / commits / 130c08c3c

Make format logic look much better

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

Jakub Sztandera committed May 17, 2016 at 15:47 UTC 130c08c3cd4a9eb554858efd884049872e228c4b
1 file changed +7 -12
core/commands/files/files.go
+7 -12
@@ -135,24 +135,19 @@ 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()
138 + format, found, _ := req.Option("format").String()
139
140 - if moreThanOne(hash, size, formatSpecified) {
140 + if moreThanOne(hash, size, found) {
141 return "", formatError
142 }
143
144 - format := ""
144 if hash {
146 - format = "<hash>"
145 + return "<hash>", nil
146 + } else if size {
147 + return "<cumulsize>", nil
148 + } else {
149 + return format, nil
150 }
148 - if size {
149 - format = "<cumulsize>"
150 - }
151 - if len(format) == 0 {
152 - format, _, _ = req.Option("format").String()
153 - }
154 -
155 - return format, nil
151 }
152
153 func statNode(ds dag.DAGService, fsn mfs.FSNode) (*Object, error) {