commands/block: don't use default for -f
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Mar 10, 2018 at 23:44 UTC
efb74199bf2d9d92fcfec28a10edceefed9adec2
1 file changed
+4
-4
core/commands/block.go
+4
-4
@@ -132,7 +132,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
132
cmdkit.FileArg("data", true, false, "The data to be stored as an IPFS block.").EnableStdin(),
133
},
134
Options: []cmdkit.Option{
135
- cmdkit.StringOption("format", "f", "cid format for blocks to be created with.").WithDefault(""),
135
+ cmdkit.StringOption("format", "f", "cid format for blocks to be created with."),
136
cmdkit.StringOption("mhtype", "multihash hash function").WithDefault("sha2-256"),
137
cmdkit.IntOption("mhlen", "multihash hash length").WithDefault(-1),
138
},
@@ -172,8 +172,8 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
172
var pref cid.Prefix
173
pref.Version = 1
174
175
- format := req.Options["format"].(string)
176
- if format == "" {
175
+ format, formatSet := req.Options["format"].(string)
176
+ if !formatSet {
177
if mhtval == mh.SHA2_256 {
178
format = "v0"
179
} else {
@@ -186,7 +186,7 @@ than 'sha2-256' or format to anything other than 'v0' will result in CIDv1.
186
}
187
formatval, ok := cid.Codecs[format]
188
if !ok {
189
- res.SetError(fmt.Errorf("unrecognized format: %s", format), cmdkit.ErrNormal)
189
+ res.SetError(fmt.Errorf("unrecognized format: '%s'", format), cmdkit.ErrNormal)
190
return
191
}
192
if mhtval != mh.SHA2_256 && pref.Version == 0 {