Add streaming to multibase-conv
This commit is contained in:
@@ -3,30 +3,32 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
multibase "github.com/multiformats/go-multibase"
|
multibase "github.com/multiformats/go-multibase"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) != 3 {
|
if len(os.Args) < 3 {
|
||||||
fmt.Printf("usage: %s CID NEW-BASE\n", os.Args[0])
|
fmt.Printf("usage: %s NEW-BASE CID...\n", os.Args[0])
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
cid := os.Args[1]
|
newBase := os.Args[1]
|
||||||
newBase := os.Args[2]
|
cids := os.Args[2:]
|
||||||
|
|
||||||
_, data, err := multibase.Decode(cid)
|
for _, cid := range cids {
|
||||||
if err != nil {
|
_, data, err := multibase.Decode(cid)
|
||||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
if err != nil {
|
||||||
os.Exit(1)
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
newCid, err := multibase.Encode(multibase.Encoding(newBase[0]), data)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
fmt.Println(newCid)
|
||||||
}
|
}
|
||||||
|
|
||||||
newCid, err := multibase.Encode(multibase.Encoding(newBase[0]), data)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("%s\n", newCid)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user