github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/cmd/ipfs/pin.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
     5  	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
     6  	"github.com/jbenet/go-ipfs/core/commands"
     7  )
     8  
     9  var cmdIpfsPin = &commander.Command{
    10  	UsageLine: "pin",
    11  	Short:     "",
    12  	Long: `ipfs pin [add|rm] - object pinning commands
    13  `,
    14  	Subcommands: []*commander.Command{
    15  		cmdIpfsSubPin,
    16  		cmdIpfsSubUnpin,
    17  	},
    18  }
    19  
    20  var cmdIpfsSubPin = &commander.Command{
    21  	UsageLine: "add",
    22  	Short:     "pin an ipfs object to local storage.",
    23  	Long: `ipfs pin add <ipfs-path> - pin ipfs object to local storage.
    24  
    25      Retrieves the object named by <ipfs-path> and stores it locally
    26      on disk.
    27  `,
    28  	Run:  pinSubCmd,
    29  	Flag: *flag.NewFlagSet("ipfs-pin", flag.ExitOnError),
    30  }
    31  
    32  var pinSubCmd = makeCommand(command{
    33  	name:  "pin",
    34  	args:  1,
    35  	flags: []string{"r", "d"},
    36  	cmdFn: commands.Pin,
    37  })
    38  
    39  var cmdIpfsSubUnpin = &commander.Command{
    40  	UsageLine: "rm",
    41  	Short:     "unpin an ipfs object from local storage.",
    42  	Long: `ipfs pin rm <ipfs-path> - unpin ipfs object from local storage.
    43  
    44  	Removes the pin from the given object allowing it to be garbage
    45  	collected if needed.
    46  `,
    47  	Run:  unpinSubCmd,
    48  	Flag: *flag.NewFlagSet("ipfs-unpin", flag.ExitOnError),
    49  }
    50  
    51  var unpinSubCmd = makeCommand(command{
    52  	name:  "unpin",
    53  	args:  1,
    54  	flags: []string{"r"},
    55  	cmdFn: commands.Unpin,
    56  })
    57  
    58  func init() {
    59  	cmdIpfsSubPin.Flag.Bool("r", false, "pin objects recursively")
    60  	cmdIpfsSubPin.Flag.Int("d", 1, "recursive depth")
    61  	cmdIpfsSubUnpin.Flag.Bool("r", false, "unpin objects recursively")
    62  }