github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/core/commands2/root.go (about)

     1  package commands
     2  
     3  import (
     4  	cmds "github.com/jbenet/go-ipfs/commands"
     5  	u "github.com/jbenet/go-ipfs/util"
     6  )
     7  
     8  var log = u.Logger("core/commands")
     9  
    10  type TestOutput struct {
    11  	Foo string
    12  	Bar int
    13  }
    14  
    15  var Root = &cmds.Command{
    16  	Description: "Global P2P Merkle-DAG filesystem",
    17  	Help: `Basic commands:
    18  
    19      init          Initialize ipfs local configurationx
    20      add <path>    Add an object to ipfs
    21      cat <ref>     Show ipfs object data
    22      ls <ref>      List links from an object
    23  
    24  Tool commands:
    25  
    26      config        Manage configuration
    27      update        Download and apply go-ipfs updates
    28      version       Show ipfs version information
    29      commands      List all available commands
    30  
    31  Advanced Commands:
    32  
    33      mount         Mount an ipfs read-only mountpoint
    34      serve         Serve an interface to ipfs
    35      diag          Print diagnostics
    36  
    37  Plumbing commands:
    38  
    39      block         Interact with raw blocks in the datastore
    40      object        Interact with raw dag nodes
    41  
    42  
    43  Use "ipfs <command> --help" for more information about a command.
    44  `,
    45  
    46  	Options: []cmds.Option{
    47  		cmds.StringOption("config", "c", "Path to the configuration file to use"),
    48  		cmds.BoolOption("debug", "D", "Operate in debug mode"),
    49  		cmds.BoolOption("help", "h", "Show the command help text"),
    50  		cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon"),
    51  	},
    52  }
    53  
    54  var rootSubcommands = map[string]*cmds.Command{
    55  	"cat":       catCmd,
    56  	"ls":        lsCmd,
    57  	"commands":  commandsCmd,
    58  	"name":      nameCmd,
    59  	"add":       addCmd,
    60  	"log":       logCmd,
    61  	"diag":      diagCmd,
    62  	"pin":       pinCmd,
    63  	"version":   versionCmd,
    64  	"config":    configCmd,
    65  	"bootstrap": bootstrapCmd,
    66  	"mount":     mountCmd,
    67  	"block":     blockCmd,
    68  	"update":    updateCmd,
    69  	"object":    objectCmd,
    70  	"refs":      refsCmd,
    71  }
    72  
    73  func init() {
    74  	Root.Subcommands = rootSubcommands
    75  	u.SetLogLevel("core/commands", "info")
    76  }
    77  
    78  type MessageOutput struct {
    79  	Message string
    80  }
    81  
    82  func MessageTextMarshaller(res cmds.Response) ([]byte, error) {
    83  	return []byte(res.Output().(*MessageOutput).Message), nil
    84  }