pin.go 1.53 KB
Newer Older
1 2 3
package main

import (
4 5 6
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
	"github.com/jbenet/go-ipfs/core/commands"
7 8 9 10
)

var cmdIpfsPin = &commander.Command{
	UsageLine: "pin",
Jeromy's avatar
Jeromy committed
11 12 13 14 15 16 17 18 19 20 21
	Short:     "",
	Long: `ipfs pin [add|rm] - object pinning commands
`,
	Subcommands: []*commander.Command{
		cmdIpfsSubPin,
		cmdIpfsSubUnpin,
	},
}

var cmdIpfsSubPin = &commander.Command{
	UsageLine: "add",
22
	Short:     "pin an ipfs object to local storage.",
Jeromy's avatar
Jeromy committed
23
	Long: `ipfs pin add <ipfs-path> - pin ipfs object to local storage.
24 25 26 27

    Retrieves the object named by <ipfs-path> and stores it locally
    on disk.
`,
Jeromy's avatar
Jeromy committed
28
	Run:  pinSubCmd,
29 30 31
	Flag: *flag.NewFlagSet("ipfs-pin", flag.ExitOnError),
}

Jeromy's avatar
Jeromy committed
32
var pinSubCmd = makeCommand(command{
33 34 35 36 37
	name:  "pin",
	args:  1,
	flags: []string{"r", "d"},
	cmdFn: commands.Pin,
})
Jeromy's avatar
Jeromy committed
38

Jeromy's avatar
Jeromy committed
39 40
var cmdIpfsSubUnpin = &commander.Command{
	UsageLine: "rm",
Jeromy's avatar
Jeromy committed
41
	Short:     "unpin an ipfs object from local storage.",
Jeromy's avatar
Jeromy committed
42
	Long: `ipfs pin rm <ipfs-path> - unpin ipfs object from local storage.
Jeromy's avatar
Jeromy committed
43 44 45 46

	Removes the pin from the given object allowing it to be garbage
	collected if needed.
`,
Jeromy's avatar
Jeromy committed
47
	Run:  unpinSubCmd,
Jeromy's avatar
Jeromy committed
48 49 50
	Flag: *flag.NewFlagSet("ipfs-unpin", flag.ExitOnError),
}

Jeromy's avatar
Jeromy committed
51
var unpinSubCmd = makeCommand(command{
Jeromy's avatar
Jeromy committed
52 53 54 55 56 57 58
	name:  "unpin",
	args:  1,
	flags: []string{"r", "d"},
	cmdFn: commands.Unpin,
})

func init() {
Jeromy's avatar
Jeromy committed
59 60 61
	cmdIpfsSubPin.Flag.Bool("r", false, "pin objects recursively")
	cmdIpfsSubPin.Flag.Int("d", 1, "recursive depth")
	cmdIpfsSubUnpin.Flag.Bool("r", false, "unpin objects recursively")
Jeromy's avatar
Jeromy committed
62
}