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

     1  package main
     2  
     3  import (
     4  	flag "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
     5  	commander "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
     6  	"github.com/jbenet/go-ipfs/core/commands"
     7  )
     8  
     9  var cmdIpfsObject = &commander.Command{
    10  	UsageLine: "object",
    11  	Short:     "interact with ipfs objects",
    12  	Long: `ipfs object - interact with ipfs objects
    13  
    14  		ipfs object data <key>  - return the data for this key as raw bytes
    15  		ipfs object links <key> - lists (the keys of ?) the links this key points to
    16  		ipfs object get <key>   - output dag object to stdout
    17  		ipfs object put         - add dag object from stdin
    18  
    19  ipfs object is a plumbing command used to manipulate dag objects directly.
    20  - <key> is a base58 encoded multihash.
    21  - It reads from stdin or writes to stdout.
    22  - It accepts multiple encodings: --encoding=[ protobuf, json, ... ]`,
    23  	Subcommands: []*commander.Command{
    24  		cmdIpfsObjectData,
    25  		cmdIpfsObjectLinks,
    26  		cmdIpfsObjectGet,
    27  		cmdIpfsObjectPut,
    28  	},
    29  	Flag: *flag.NewFlagSet("ipfs-object", flag.ExitOnError),
    30  }
    31  
    32  var cmdIpfsObjectData = &commander.Command{
    33  	UsageLine: "data <key>",
    34  	Short:     "data outputs the raw bytes named by <key>",
    35  	Long: `ipfs data <key> - data outputs the raw bytes named by <key>
    36  
    37  ipfs data is a plumbing command for retreiving the raw bytes stored in a dag node.
    38  It outputs to stdout, and <key> is a base58 encoded multihash.`,
    39  	Run: makeCommand(command{
    40  		name:   "objectData",
    41  		args:   1,
    42  		flags:  nil,
    43  		online: true,
    44  		cmdFn:  commands.ObjectData,
    45  	}),
    46  }
    47  
    48  var cmdIpfsObjectLinks = &commander.Command{
    49  	UsageLine: "links <key>",
    50  	Short:     "outputs the links pointed to by <key>",
    51  	Long: `ipfs links <key> - outputs the links pointed to by <key>
    52  
    53  ipfs block get is a plumbing command for retreiving raw ipfs blocks.
    54  It outputs to stdout, and <key> is a base58 encoded multihash.`,
    55  	Run: makeCommand(command{
    56  		name:   "objectLinks",
    57  		args:   1,
    58  		flags:  nil,
    59  		online: true,
    60  		cmdFn:  commands.ObjectLinks,
    61  	}),
    62  }
    63  
    64  func init() {
    65  	cmdIpfsObjectGet.Flag.String("encoding", "json", "the encoding to use..")
    66  	cmdIpfsObjectPut.Flag.String("encoding", "json", "the encoding to use..")
    67  }
    68  
    69  var cmdIpfsObjectGet = &commander.Command{
    70  	UsageLine: "get <key>",
    71  	Short:     "get and serialize the dag node named by <key>",
    72  	Long: `ipfs get <key> - get and output the dag node named by <key>
    73  
    74  ipfs object get is a plumbing command for retreiving dag nodes.
    75  It serialize the dag node to the format specified by the format flag.
    76  It outputs to stdout, and <key> is a base58 encoded multihash.
    77  
    78  Formats:
    79  
    80  This command outputs and accepts data in a variety of encodings: protobuf, json, etc.
    81  Use the --encoding flag
    82  `,
    83  	Run: makeCommand(command{
    84  		name:   "blockGet",
    85  		args:   1,
    86  		flags:  []string{"encoding"},
    87  		online: true,
    88  		cmdFn:  commands.ObjectGet,
    89  	}),
    90  }
    91  
    92  var cmdIpfsObjectPut = &commander.Command{
    93  	UsageLine: "put",
    94  	Short:     "store stdin as a dag object, outputs <key>",
    95  	Long: `ipfs put - store stdin as a dag object, outputs <key>
    96  
    97  ipfs object put is a plumbing command for storing dag nodes.
    98  It serialize the dag node to the format specified by the format flag.
    99  It reads from stding, and <key> is a base58 encoded multihash.
   100  
   101  Formats:
   102  
   103  This command outputs and accepts data in a variety of encodings: protobuf, json, etc.
   104  Use the --encoding flag`,
   105  	Run: makeCommand(command{
   106  		name:   "blockPut",
   107  		args:   0,
   108  		flags:  []string{"encoding"},
   109  		online: true,
   110  		cmdFn:  commands.ObjectPut,
   111  	}),
   112  }