Skip to content

Commit

Permalink
Merge pull request #7149 from filecoin-project/feat/shed-cidid-raw
Browse files Browse the repository at this point in the history
shed: Support raw encoding in cid id
  • Loading branch information
magik6k authored Aug 20, 2021
2 parents 5bdc186 + 69204ee commit c05eb12
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/lotus-shed/cid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"))
}
Expand Down

0 comments on commit c05eb12

Please sign in to comment.