shed: Support raw encoding in cid id
This commit is contained in:
parent
5bdc1862d9
commit
69204eea04
@ -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"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user