Merge pull request #7149 from filecoin-project/feat/shed-cidid-raw

shed: Support raw encoding in cid id
This commit is contained in:
Łukasz Magiera 2021-08-20 17:50:19 +02:00 committed by GitHub
commit c05eb1251b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,9 +26,10 @@ var cidIdCmd = &cli.Command{
ArgsUsage: "[data]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "encoding",
Value: "base64",
Usage: "specify input encoding to parse",
Name: "encoding",
Aliases: []string{"e"},
Value: "base64",
Usage: "specify input encoding to parse",
},
&cli.StringFlag{
Name: "codec",
@ -49,12 +50,14 @@ var cidIdCmd = &cli.Command{
return xerrors.Errorf("decoding base64 value: %w", err)
}
dec = data
case "hex":
case "hex", "x":
data, err := hex.DecodeString(cctx.Args().First())
if err != nil {
return xerrors.Errorf("decoding hex value: %w", err)
}
dec = data
case "raw", "r":
dec = []byte(cctx.Args().First())
default:
return xerrors.Errorf("unrecognized encoding: %s", cctx.String("encoding"))
}