shed: Support raw encoding in cid id
This commit is contained in:
parent
5bdc1862d9
commit
69204eea04
@ -27,6 +27,7 @@ var cidIdCmd = &cli.Command{
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "encoding",
|
||||
Aliases: []string{"e"},
|
||||
Value: "base64",
|
||||
Usage: "specify input encoding to parse",
|
||||
},
|
||||
@ -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