root.go 2.37 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
	Helptext: cmds.HelpText{
17 18 19 20
		Tagline: "global p2p merkle-dag filesystem",
		Synopsis: `
ipfs [<flags>] <command> [<arg>] ...
`,
21 22
		ShortDescription: `
Basic commands:
23

24 25 26 27
    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
28 29 30

Tool commands:

31 32 33 34
    config        Manage configuration
    update        Download and apply go-ipfs updates
    version       Show ipfs version information
    commands      List all available commands
Jeromy's avatar
Jeromy committed
35
    id            Show info about ipfs peers
36 37 38

Advanced Commands:

39
    daemon        Start a long-running daemon process
40 41 42
    mount         Mount an ipfs read-only mountpoint
    serve         Serve an interface to ipfs
    diag          Print diagnostics
43 44 45 46 47

Plumbing commands:

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

Use 'ipfs <command> --help' to learn more about each command.
50
`,
51
	},
52
	Options: []cmds.Option{
53 54
		cmds.StringOption("config", "c", "Path to the configuration file to use"),
		cmds.BoolOption("debug", "D", "Operate in debug mode"),
55 56
		cmds.BoolOption("help", "Show the full command help text"),
		cmds.BoolOption("h", "Show a short version of the command help text"),
57
		cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon"),
58
	},
59 60
}

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

64
var rootSubcommands = map[string]*cmds.Command{
65 66 67 68
	"add":       AddCmd,
	"block":     BlockCmd,
	"bootstrap": BootstrapCmd,
	"cat":       CatCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
69
	"commands":  CommandsDaemonCmd,
70
	"config":    ConfigCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
71
	"diag":      DiagCmd,
72 73 74 75 76 77 78 79 80
	"id":        IDCmd,
	"log":       LogCmd,
	"ls":        LsCmd,
	"mount":     MountCmd,
	"name":      NameCmd,
	"object":    ObjectCmd,
	"pin":       PinCmd,
	"refs":      RefsCmd,
	"swarm":     SwarmCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
81
	"update":    UpdateCmd,
82
	"version":   VersionCmd,
83
}
84 85

func init() {
86
	Root.Subcommands = rootSubcommands
87
}
88 89 90 91 92

type MessageOutput struct {
	Message string
}

93
func MessageTextMarshaler(res cmds.Response) ([]byte, error) {
94
	return []byte(res.Output().(*MessageOutput).Message), nil
95
}