mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 09:59:13 +08:00
object links: Added text marshaling
This commit is contained in:

committed by
Juan Batiz-Benet

parent
7bd7624ccc
commit
b3da13a4af
@ -82,11 +82,7 @@ it contains, with the following format:
|
|||||||
if len(output) > 1 {
|
if len(output) > 1 {
|
||||||
s += fmt.Sprintf("%s:\n", object.Hash)
|
s += fmt.Sprintf("%s:\n", object.Hash)
|
||||||
}
|
}
|
||||||
|
s += marshalLinks(object.Links)
|
||||||
for _, link := range object.Links {
|
|
||||||
s += fmt.Sprintf("%s %v %s\n", link.Hash, link.Size, link.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(output) > 1 {
|
if len(output) > 1 {
|
||||||
s += "\n"
|
s += "\n"
|
||||||
}
|
}
|
||||||
@ -97,3 +93,10 @@ it contains, with the following format:
|
|||||||
},
|
},
|
||||||
Type: &LsOutput{},
|
Type: &LsOutput{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func marshalLinks(links []Link) (s string) {
|
||||||
|
for _, link := range links {
|
||||||
|
s += fmt.Sprintf("%s %v %s\n", link.Hash, link.Size, link.Name)
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
@ -108,6 +108,13 @@ It outputs to stdout, and <key> is a base58 encoded multihash.
|
|||||||
|
|
||||||
return objectLinks(n, key)
|
return objectLinks(n, key)
|
||||||
},
|
},
|
||||||
|
Marshalers: cmds.MarshalerMap{
|
||||||
|
cmds.Text: func(res cmds.Response) ([]byte, error) {
|
||||||
|
object := res.Output().(*Object)
|
||||||
|
marshalled := marshalLinks(object.Links)
|
||||||
|
return []byte(marshalled), nil
|
||||||
|
},
|
||||||
|
},
|
||||||
Type: &Object{},
|
Type: &Object{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user