root.go 2.15 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 18 19
	Helptext: cmds.HelpText{
		Tagline: "Global P2P Merkle-DAG filesystem",
		ShortDescription: `
Basic commands:
20

21 22 23 24
    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
25 26 27

Tool commands:

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

Advanced Commands:

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

Plumbing commands:

    block         Interact with raw blocks in the datastore
    object        Interact with raw dag nodes
43
`,
44
	},
45
	Options: []cmds.Option{
46 47
		cmds.StringOption("config", "c", "Path to the configuration file to use"),
		cmds.BoolOption("debug", "D", "Operate in debug mode"),
48 49
		cmds.BoolOption("help", "Show the full command help text"),
		cmds.BoolOption("h", "Show a short version of the command help text"),
50
		cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon"),
51
	},
52 53
}

Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
54 55 56
// commandsDaemonCmd is the "ipfs commands" command for daemon
var CommandsDaemonCmd = CommandsCmd(Root)

57
var rootSubcommands = map[string]*cmds.Command{
58 59
	"cat":       catCmd,
	"ls":        lsCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
60
	"commands":  CommandsDaemonCmd,
61 62
	"name":      nameCmd,
	"add":       addCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
63 64
	"log":       LogCmd,
	"diag":      DiagCmd,
65
	"pin":       pinCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
66
	"version":   VersionCmd,
67 68
	"config":    configCmd,
	"bootstrap": bootstrapCmd,
69
	"mount":     mountCmd,
70
	"block":     blockCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
71
	"update":    UpdateCmd,
72
	"object":    objectCmd,
73
	"refs":      refsCmd,
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 MessageTextMarshaler(res cmds.Response) ([]byte, error) {
86
	return []byte(res.Output().(*MessageOutput).Message), nil
87
}