use the builtin option parser to set the default for `ipfs pin ls --type`
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Mar 15, 2016 at 21:01 UTC
f15abc223cdf2f225cdafff528674e03080c423b
1 file changed
+8
-12
core/commands/pin.go
+8
-12
@@ -187,7 +187,7 @@ Example:
187
cmds.StringArg("ipfs-path", false, true, "Path to object(s) to be listed."),
188
},
189
Options: []cmds.Option{
190
- cmds.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\". Defaults to \"recursive\"."),
190
+ cmds.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").Default("all"),
191
cmds.BoolOption("count", "n", "Show refcount when listing indirect pins."),
192
cmds.BoolOption("quiet", "q", "Write just hashes of objects."),
193
},
@@ -198,22 +198,18 @@ Example:
198
return
199
}
200
201
- typeStr, typeStrFound, err := req.Option("type").String()
201
+ typeStr, _, err := req.Option("type").String()
202
if err != nil {
203
res.SetError(err, cmds.ErrNormal)
204
return
205
}
206
207
- if typeStrFound {
208
- switch typeStr {
209
- case "all", "direct", "indirect", "recursive":
210
- default:
211
- err = fmt.Errorf("Invalid type '%s', must be one of {direct, indirect, recursive, all}", typeStr)
212
- res.SetError(err, cmds.ErrClient)
213
- return
214
- }
215
- } else {
216
- typeStr = "all"
207
+ switch typeStr {
208
+ case "all", "direct", "indirect", "recursive":
209
+ default:
210
+ err = fmt.Errorf("Invalid type '%s', must be one of {direct, indirect, recursive, all}", typeStr)
211
+ res.SetError(err, cmds.ErrClient)
212
+ return
213
}
214
215
var keys map[string]RefKeyObject