From 4ec37b6f7ba672b3f68c4a4c75ce55c10fcfc7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Thu, 11 Jul 2019 14:05:05 +0200 Subject: [PATCH] pin cmd: document pin ls output types --- core/commands/pin.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/core/commands/pin.go b/core/commands/pin.go index 10fd4b242..c5a774702 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -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 {