github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/cmd/ipfs/add.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "path/filepath" 6 7 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag" 8 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander" 9 "github.com/jbenet/go-ipfs/core/commands" 10 ) 11 12 // Error indicating the max depth has been exceded. 13 var ErrDepthLimitExceeded = fmt.Errorf("depth limit exceeded") 14 15 var cmdIpfsAdd = &commander.Command{ 16 UsageLine: "add", 17 Short: "Add an object to ipfs.", 18 Long: `ipfs add <path>... - Add objects to ipfs. 19 20 Adds contents of <path> to ipfs. Use -r to add directories. 21 Note that directories are added recursively, to form the ipfs 22 MerkleDAG. A smarter partial add with a staging area (like git) 23 remains to be implemented. 24 `, 25 Run: addCmd, 26 Flag: *flag.NewFlagSet("ipfs-add", flag.ExitOnError), 27 } 28 29 func init() { 30 cmdIpfsAdd.Flag.Bool("r", false, "add objects recursively") 31 } 32 33 var addCmd = makeCommand(command{ 34 name: "add", 35 args: 1, 36 flags: []string{"r"}, 37 cmdFn: commands.Add, 38 argFilter: filepath.Abs, 39 })