pin cmd: document pin ls output types

This commit is contained in:
Michael Muré 2019-07-11 14:05:05 +02:00
parent 58ea970135
commit 4ec37b6f7b
No known key found for this signature in database
GPG Key ID: A4457C029293126F

View File

@ -393,19 +393,7 @@ Example:
},
}
type PinLsObject struct {
Cid string `json:",omitempty"`
Type string `json:",omitempty"`
}
type PinLsType struct {
Type string
}
type PinLsList struct {
Keys map[string]PinLsType `json:",omitempty"`
}
// PinLsOutputWrapper is the output type of the pin ls command.
// Pin ls needs to output two different type depending on if it's streamed or not.
// We use this to bypass the cmds lib refusing to have interface{}
type PinLsOutputWrapper struct {
@ -413,6 +401,22 @@ type PinLsOutputWrapper struct {
PinLsObject
}
// PinLsList is a set of pins with their type
type PinLsList struct {
Keys map[string]PinLsType `json:",omitempty"`
}
// PinLsType contains the type of a pin
type PinLsType struct {
Type string
}
// PinLsObject contains the description of a pin
type PinLsObject struct {
Cid string `json:",omitempty"`
Type string `json:",omitempty"`
}
func pinLsKeys(req *cmds.Request, typeStr string, n *core.IpfsNode, api coreiface.CoreAPI, emit func(value interface{}) error) error {
mode, ok := pin.StringToMode(typeStr)
if !ok {