root.go 2.06 KB
Newer Older
1 2 3
package commands

import (
4
	cmds "github.com/jbenet/go-ipfs/commands"
Matt Bell's avatar
Matt Bell committed
5
	u "github.com/jbenet/go-ipfs/util"
6 7
)

Matt Bell's avatar
Matt Bell committed
8 9
var log = u.Logger("core/commands")

10 11 12 13 14 15
type TestOutput struct {
	Foo string
	Bar int
}

var Root = &cmds.Command{
16 17
	Description: "Global P2P Merkle-DAG filesystem",
	Help: `Basic commands:
18

19 20 21 22
    init          Initialize ipfs local configurationx
    add <path>    Add an object to ipfs
    cat <ref>     Show ipfs object data
    ls <ref>      List links from an object
23 24 25

Tool commands:

26 27 28 29
    config        Manage configuration
    update        Download and apply go-ipfs updates
    version       Show ipfs version information
    commands      List all available commands
30 31 32

Advanced Commands:

33 34 35
    mount         Mount an ipfs read-only mountpoint
    serve         Serve an interface to ipfs
    diag          Print diagnostics
36 37 38 39 40 41

Plumbing commands:

    block         Interact with raw blocks in the datastore
    object        Interact with raw dag nodes

42

43
Use "ipfs <command> --help" for more information about a command.
44
`,
45 46 47 48 49 50 51 52 53 54 55

	Options: []cmds.Option{
		cmds.Option{[]string{"config", "c"}, cmds.String,
			"Path to the configuration file to use"},
		cmds.Option{[]string{"debug", "D"}, cmds.Bool,
			"Operate in debug mode"},
		cmds.Option{[]string{"help", "h"}, cmds.Bool,
			"Show the command help text"},
		cmds.Option{[]string{"local", "L"}, cmds.Bool,
			"Run the command locally, instead of using the daemon"},
	},
56 57 58
}

var rootSubcommands = map[string]*cmds.Command{
59 60 61 62 63 64
	"cat":       catCmd,
	"ls":        lsCmd,
	"commands":  commandsCmd,
	"name":      nameCmd,
	"add":       addCmd,
	"log":       logCmd,
Brian Tiger Chow's avatar
Brian Tiger Chow committed
65
	"diag":      diagCmd,
66 67 68 69
	"pin":       pinCmd,
	"version":   versionCmd,
	"config":    configCmd,
	"bootstrap": bootstrapCmd,
70
	"mount":     mountCmd,
71
	"block":     blockCmd,
72
	"update":    updateCmd,
73
	"object":    objectCmd,
74
}
75 76

func init() {
77
	Root.Subcommands = rootSubcommands
Matt Bell's avatar
Matt Bell committed
78
	u.SetLogLevel("core/commands", "info")
79
}
80 81 82 83 84

type MessageOutput struct {
	Message string
}

85
func MessageTextMarshaller(res cmds.Response) ([]byte, error) {
86
	return []byte(res.Output().(*MessageOutput).Message), nil
87
}