root.go 2.09 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 23 24 25 26 27

    init          Initialize ipfs local configuration.
    add <path>    Add an object to ipfs.
    cat <ref>     Show ipfs object data.
    ls <ref>      List links from an object.
    refs <ref>    List link hashes from an object.

Tool commands:

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

Advanced Commands:

    mount         Mount an ipfs read-only mountpoint.
    serve         Serve an interface to ipfs.
36 37 38 39 40 41 42
    net-diag      Print network diagnostic

Plumbing commands:

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

43 44 45

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

	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"},
	},
57 58 59
}

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