From ef4e8837c69d8af8e262b6c4497bb7b4d645dc13 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 15 Mar 2016 16:55:26 -0400 Subject: [PATCH 1/2] change `ipfs pin` response field name from `Pinned` to `Pins` This way, we don't claim to pin when unpinning. License: MIT Signed-off-by: Steven Allen --- core/commands/pin.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/commands/pin.go b/core/commands/pin.go index 4bf250d0167..f99181939df 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -28,7 +28,7 @@ var PinCmd = &cmds.Command{ } type PinOutput struct { - Pinned []key.Key + Pins []key.Key } var addPinCmd = &cmds.Command{ @@ -84,7 +84,7 @@ var addPinCmd = &cmds.Command{ } buf := new(bytes.Buffer) - for _, k := range added.Pinned { + for _, k := range added.Pins { fmt.Fprintf(buf, "pinned %s %s\n", k, pintype) } return buf, nil @@ -138,7 +138,7 @@ collected if needed. (By default, recursively. Use -r=false for direct pins) } buf := new(bytes.Buffer) - for _, k := range added.Pinned { + for _, k := range added.Pins { fmt.Fprintf(buf, "unpinned %s\n", k) } return buf, nil From f15abc223cdf2f225cdafff528674e03080c423b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 15 Mar 2016 21:01:09 -0400 Subject: [PATCH 2/2] use the builtin option parser to set the default for `ipfs pin ls --type` License: MIT Signed-off-by: Steven Allen --- core/commands/pin.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/core/commands/pin.go b/core/commands/pin.go index f99181939df..65cee488150 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -187,7 +187,7 @@ Example: cmds.StringArg("ipfs-path", false, true, "Path to object(s) to be listed."), }, Options: []cmds.Option{ - cmds.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\". Defaults to \"recursive\"."), + cmds.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").Default("all"), cmds.BoolOption("count", "n", "Show refcount when listing indirect pins."), cmds.BoolOption("quiet", "q", "Write just hashes of objects."), }, @@ -198,22 +198,18 @@ Example: return } - typeStr, typeStrFound, err := req.Option("type").String() + typeStr, _, err := req.Option("type").String() if err != nil { res.SetError(err, cmds.ErrNormal) return } - if typeStrFound { - switch typeStr { - case "all", "direct", "indirect", "recursive": - default: - err = fmt.Errorf("Invalid type '%s', must be one of {direct, indirect, recursive, all}", typeStr) - res.SetError(err, cmds.ErrClient) - return - } - } else { - typeStr = "all" + switch typeStr { + case "all", "direct", "indirect", "recursive": + default: + err = fmt.Errorf("Invalid type '%s', must be one of {direct, indirect, recursive, all}", typeStr) + res.SetError(err, cmds.ErrClient) + return } var keys map[string]RefKeyObject