block.go 1.67 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
package main

import (
	flag "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
	commander "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
	"github.com/jbenet/go-ipfs/core/commands"
)

var cmdIpfsBlock = &commander.Command{
	UsageLine: "block",
Henry's avatar
Henry committed
11 12
	Short:     "manipulate raw ipfs blocks",
	Long: `ipfs block - manipulate raw ipfs blocks
13

Henry's avatar
Henry committed
14 15 16 17 18 19
    ipfs block get <key>  - get and output block named by <key>
    ipfs block put        - store stdin as a block, outputs <key>

ipfs block is a plumbing command used to manipulate raw ipfs blocks.
Reads from stdin or writes to stdout, and <key> is a base58 encoded
multihash.`,
20 21 22 23 24 25 26 27 28
	// Run: blockGetCmd,
	Subcommands: []*commander.Command{
		cmdIpfsBlockGet,
		cmdIpfsBlockPut,
	},
	Flag: *flag.NewFlagSet("ipfs-block", flag.ExitOnError),
}

var cmdIpfsBlockGet = &commander.Command{
Henry's avatar
Henry committed
29 30 31 32 33 34
	UsageLine: "get <key>",
	Short:     "get and output block named by <key>",
	Long: `ipfs get <key> - get and output block named by <key>

ipfs block get is a plumbing command for retreiving raw ipfs blocks.
It outputs to stdout, and <key> is a base58 encoded multihash.`,
35
	Run: makeCommand(command{
36
		name:   "blockGet",
37 38 39 40 41 42 43 44 45
		args:   1,
		flags:  nil,
		online: true,
		cmdFn:  commands.BlockGet,
	}),
}

var cmdIpfsBlockPut = &commander.Command{
	UsageLine: "put",
Henry's avatar
Henry committed
46 47 48 49 50
	Short:     "store stdin as a block, outputs <key>",
	Long: `ipfs put - store stdin as a block, outputs <key>

ipfs block put is a plumbing command for storing raw ipfs blocks.
It reads from stding, and <key> is a base58 encoded multihash.`,
51
	Run: makeCommand(command{
52
		name:   "blockPut",
53
		args:   0,
54 55 56 57 58
		flags:  nil,
		online: true,
		cmdFn:  commands.BlockPut,
	}),
}