Commit 14a384d8 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

pin: add depth arg.

parent 728f17d3
......@@ -20,6 +20,7 @@ var cmdIpfsPin = &commander.Command{
func init() {
cmdIpfsPin.Flag.Bool("r", false, "pin objects recursively")
cmdIpfsPin.Flag.Int("d", 1, "recursive depth")
}
var pinCmd = MakeCommand("pin", []string{"r"}, commands.Pin)
var pinCmd = MakeCommand("pin", []string{"r", "d"}, commands.Pin)
......@@ -9,12 +9,20 @@ import (
func Pin(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Writer) error {
// if recursive, set flag
depth := 1
if r, ok := opts["r"].(bool); r && ok {
depth = -1
// set recursive flag
recursive, _ := opts["r"].(bool) // false if cast fails.
// if recursive, set depth flag
depth := 1 // default (non recursive)
if d, ok := opts["d"].(int); recursive && ok {
depth = d
}
if depth < -1 {
return fmt.Errorf("ipfs pin: called with invalid depth: %v", depth)
}
fmt.Printf("recursive, depth: %v, %v\n", recursive, depth)
for _, fn := range args {
dagnode, err := n.Resolver.ResolvePath(fn)
if err != nil {
......
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