1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-29 01:12:24 +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: build:
go build go build
mv cli ipfs 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 return nil
} }
// for now only hashes, no path resolution
h, err := mh.FromB58String(inp[0])
if err != nil {
return err
}
n, err := localNode() n, err := localNode()
if err != nil { if err != nil {
return err return err
} }
nd, err := n.GetDagNode(u.Key(h)) for _, fn := range inp {
if err != nil { // for now only hashes, no path resolution
return err 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 return nil
} }

View File

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