6
6
"sort"
7
7
"strings"
8
8
"unicode"
9
+
10
+ "github.com/ipfs/go-ipfs/core/commands/e"
9
11
10
12
cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid"
11
13
cmds "gx/ipfs/QmPXR4tNdLbp8HsZiPMjpsgqphX9Vhw2J6Jh5MKH2ovW3D/go-ipfs-cmds"
@@ -66,7 +68,7 @@ The optional format string is a printf style format string:
66
68
case "1" :
67
69
opts .verConv = toCidV1
68
70
default :
69
- return fmt .Errorf ("invalid cid version: %s\n " , verStr )
71
+ return fmt .Errorf ("invalid cid version: %s" , verStr )
70
72
}
71
73
72
74
if baseStr != "" {
@@ -82,7 +84,7 @@ The optional format string is a printf style format string:
82
84
return emitCids (req , resp , opts )
83
85
},
84
86
PostRun : cmds.PostRunMap {
85
- cmds .CLI : streamRes (func (v interface {}, out io.Writer ) nonFatalError {
87
+ cmds .CLI : streamResults (func (v interface {}, out io.Writer ) nonFatalError {
86
88
r := v .(* CidFormatRes )
87
89
if r .ErrorMsg != "" {
88
90
return nonFatalError (fmt .Sprintf ("%s: %s" , r .CidStr , r .ErrorMsg ))
@@ -230,7 +232,10 @@ var basesCmd = &cmds.Command{
230
232
cmds .Text : cmds .MakeEncoder (func (req * cmds.Request , w io.Writer , val0 interface {}) error {
231
233
prefixes , _ := req .Options ["prefix" ].(bool )
232
234
numeric , _ := req .Options ["numeric" ].(bool )
233
- val := val0 .([]CodeAndName )
235
+ val , ok := val0 .([]CodeAndName )
236
+ if ! ok {
237
+ return e .TypeErr (val , val0 )
238
+ }
234
239
sort .Sort (multibaseSorter {val })
235
240
for _ , v := range val {
236
241
code := v .Code
@@ -274,7 +279,10 @@ var codecsCmd = &cmds.Command{
274
279
Encoders : cmds.EncoderMap {
275
280
cmds .Text : cmds .MakeEncoder (func (req * cmds.Request , w io.Writer , val0 interface {}) error {
276
281
numeric , _ := req .Options ["numeric" ].(bool )
277
- val := val0 .([]CodeAndName )
282
+ val , ok := val0 .([]CodeAndName )
283
+ if ! ok {
284
+ return e .TypeErr (val , val0 )
285
+ }
278
286
sort .Sort (codeAndNameSorter {val })
279
287
for _ , v := range val {
280
288
if numeric {
0 commit comments