Skip to content

Commit 70c13cf

Browse files
committed
chore: go-multicodec v0.4.1 + helptext fixes
1 parent e348b59 commit 70c13cf

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

core/commands/cid.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The optional format string is a printf style format string:
4848
` + cidutil.FormatRef,
4949
},
5050
Arguments: []cmds.Argument{
51-
cmds.StringArg("cid", true, true, "Cids to format.").EnableStdin(),
51+
cmds.StringArg("cid", true, true, "CIDs to format.").EnableStdin(),
5252
},
5353
Options: []cmds.Option{
5454
cmds.StringOption(cidFormatOptionName, "Printf style format string.").WithDefault("%s"),
@@ -65,14 +65,14 @@ The optional format string is a printf style format string:
6565
opts := cidFormatOpts{}
6666

6767
if strings.IndexByte(fmtStr, '%') == -1 {
68-
return fmt.Errorf("invalid format string: %s", fmtStr)
68+
return fmt.Errorf("invalid format string: %q", fmtStr)
6969
}
7070
opts.fmtStr = fmtStr
7171

7272
if codecStr != "" {
7373
codec, ok := cid.Codecs[codecStr]
7474
if !ok {
75-
return fmt.Errorf("unknown IPLD codec: %s", codecStr)
75+
return fmt.Errorf("unknown IPLD codec: %q", codecStr)
7676
}
7777
opts.newCodec = codec
7878
} // otherwise, leave it as 0 (not a valid IPLD codec)
@@ -82,13 +82,13 @@ The optional format string is a printf style format string:
8282
// noop
8383
case "0":
8484
if opts.newCodec != 0 && opts.newCodec != cid.DagProtobuf {
85-
return fmt.Errorf("cannot convert to CIDv0 with any codec other than DagPB")
85+
return fmt.Errorf("cannot convert to CIDv0 with any codec other than dag-pb")
8686
}
8787
opts.verConv = toCidV0
8888
case "1":
8989
opts.verConv = toCidV1
9090
default:
91-
return fmt.Errorf("invalid cid version: %s", verStr)
91+
return fmt.Errorf("invalid cid version: %q", verStr)
9292
}
9393

9494
if baseStr != "" {
@@ -125,9 +125,13 @@ type CidFormatRes struct {
125125
var base32Cmd = &cmds.Command{
126126
Helptext: cmds.HelpText{
127127
Tagline: "Convert CIDs to Base32 CID version 1.",
128+
ShortDescription: `
129+
'ipfs cid base32' normalizes passes CIDs to their canonical case-insensitive encoding.
130+
Useful when processing third-party CIDs which could come with arbitrary formats.
131+
`,
128132
},
129133
Arguments: []cmds.Argument{
130-
cmds.StringArg("cid", true, true, "Cids to convert.").EnableStdin(),
134+
cmds.StringArg("cid", true, true, "CIDs to convert.").EnableStdin(),
131135
},
132136
Run: func(req *cmds.Request, resp cmds.ResponseEmitter, env cmds.Environment) error {
133137
opts := cidFormatOpts{
@@ -234,7 +238,7 @@ func emitCids(req *cmds.Request, resp cmds.ResponseEmitter, opts cidFormatOpts)
234238

235239
func toCidV0(c cid.Cid) (cid.Cid, error) {
236240
if c.Type() != cid.DagProtobuf {
237-
return cid.Cid{}, fmt.Errorf("can't convert non-protobuf nodes to cidv0")
241+
return cid.Cid{}, fmt.Errorf("can't convert non-dag-pb nodes to cidv0")
238242
}
239243
return cid.NewCidV0(c.Hash()), nil
240244
}
@@ -256,6 +260,9 @@ const (
256260
var basesCmd = &cmds.Command{
257261
Helptext: cmds.HelpText{
258262
Tagline: "List available multibase encodings.",
263+
ShortDescription: `
264+
'ipfs cid bases' relies on https://github.com/multiformats/go-multibase
265+
`,
259266
},
260267
Options: []cmds.Option{
261268
cmds.BoolOption(prefixOptionName, "also include the single letter prefixes in addition to the code"),
@@ -305,6 +312,9 @@ const (
305312
var codecsCmd = &cmds.Command{
306313
Helptext: cmds.HelpText{
307314
Tagline: "List available CID codecs.",
315+
ShortDescription: `
316+
'ipfs cid codecs' relies on https://github.com/multiformats/go-multicodec
317+
`,
308318
},
309319
Options: []cmds.Option{
310320
cmds.BoolOption(codecsNumericOptionName, "n", "also include numeric codes"),
@@ -355,6 +365,9 @@ var codecsCmd = &cmds.Command{
355365
var hashesCmd = &cmds.Command{
356366
Helptext: cmds.HelpText{
357367
Tagline: "List available multihashes.",
368+
ShortDescription: `
369+
'ipfs cid hashes' relies on https://github.com/multiformats/go-multihash
370+
`,
358371
},
359372
Options: codecsCmd.Options,
360373
Run: func(req *cmds.Request, resp cmds.ResponseEmitter, env cmds.Environment) error {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ require (
9696
github.com/multiformats/go-multiaddr v0.5.0
9797
github.com/multiformats/go-multiaddr-dns v0.3.1
9898
github.com/multiformats/go-multibase v0.0.3
99-
github.com/multiformats/go-multicodec v0.4.0
99+
github.com/multiformats/go-multicodec v0.4.1
100100
github.com/multiformats/go-multihash v0.1.0
101101
github.com/opentracing/opentracing-go v1.2.0
102102
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,8 @@ github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPw
11881188
github.com/multiformats/go-multicodec v0.2.0/go.mod h1:/y4YVwkfMyry5kFbMTbLJKErhycTIftytRV+llXdyS4=
11891189
github.com/multiformats/go-multicodec v0.3.0/go.mod h1:qGGaQmioCDh+TeFOnxrbU0DaIPw8yFgAZgFG0V7p1qQ=
11901190
github.com/multiformats/go-multicodec v0.3.1-0.20210902112759-1539a079fd61/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ=
1191-
github.com/multiformats/go-multicodec v0.4.0 h1:fbqb6ky7erjdD+/zaEBJgZWu1i8D6i/wmPywGK7sdow=
1192-
github.com/multiformats/go-multicodec v0.4.0/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ=
1191+
github.com/multiformats/go-multicodec v0.4.1 h1:BSJbf+zpghcZMZrwTYBGwy0CPcVZGWiC72Cp8bBd4R4=
1192+
github.com/multiformats/go-multicodec v0.4.1/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ=
11931193
github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U=
11941194
github.com/multiformats/go-multihash v0.0.5/go.mod h1:lt/HCbqlQwlPBz7lv0sQCdtfcMtlJvakRUn/0Ual8po=
11951195
github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew=

test/sharness/t0290-cid.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ cat <<EOF > supported_codecs_expect
151151
112 dag-pb
152152
113 dag-cbor
153153
120 git-raw
154+
133 dag-jose
154155
297 dag-json
155156
512 json
156157
EOF

0 commit comments

Comments
 (0)