1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 08:47:42 +08:00

cat and ls multifile

This commit is contained in:
Juan Batiz-Benet
2014-07-05 22:07:20 -07:00
parent 5abf3c2ae9
commit e4ee16fac1
3 changed files with 30 additions and 23 deletions

View File

@ -3,3 +3,6 @@ all: build
build:
go build
mv cli ipfs
install: build
cp ipfs /usr/local/bin/ipfs

View File

@ -25,22 +25,24 @@ func catCmd(c *commander.Command, inp []string) error {
return nil
}
// for now only hashes, no path resolution
h, err := mh.FromB58String(inp[0])
if err != nil {
return err
}
n, err := localNode()
if err != nil {
return err
}
nd, err := n.GetDagNode(u.Key(h))
if err != nil {
return err
}
for _, fn := range inp {
// for now only hashes, no path resolution
h, err := mh.FromB58String(fn)
if err != nil {
return err
}
u.POut("%s", nd.Data)
nd, err := n.GetDagNode(u.Key(h))
if err != nil {
return err
}
u.POut("%s", nd.Data)
}
return nil
}

View File

@ -28,24 +28,26 @@ func lsCmd(c *commander.Command, inp []string) error {
return nil
}
// for now only hashes, no path resolution
h, err := mh.FromB58String(inp[0])
if err != nil {
return err
}
n, err := localNode()
if err != nil {
return err
}
nd, err := n.GetDagNode(u.Key(h))
if err != nil {
return err
}
for _, fn := range inp {
// for now only hashes, no path resolution
h, err := mh.FromB58String(fn)
if err != nil {
return err
}
for _, link := range nd.Links {
u.POut("%s %d %s\n", link.Hash.B58String(), link.Size, link.Name)
nd, err := n.GetDagNode(u.Key(h))
if err != nil {
return err
}
for _, link := range nd.Links {
u.POut("%s %d %s\n", link.Hash.B58String(), link.Size, link.Name)
}
}
return nil
}