Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin command fixes #2477

Merged
merged 2 commits into from
Mar 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var PinCmd = &cmds.Command{
}

type PinOutput struct {
Pinned []key.Key
Pins []key.Key
}

var addPinCmd = &cmds.Command{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."),
},
Expand All @@ -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
Expand Down