Commit f15abc22 authored by Steven Allen's avatar Steven Allen

use the builtin option parser to set the default for `ipfs pin ls --type`

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent ef4e8837
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment