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

import (
4 5 6
	"io"
	"strings"

7
	cmds "github.com/jbenet/go-ipfs/commands"
Matt Bell's avatar
Matt Bell committed
8
	u "github.com/jbenet/go-ipfs/util"
9 10
)

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

13 14 15 16 17 18
type TestOutput struct {
	Foo string
	Bar int
}

var Root = &cmds.Command{
19
	Helptext: cmds.HelpText{
20 21 22 23
		Tagline: "global p2p merkle-dag filesystem",
		Synopsis: `
ipfs [<flags>] <command> [<arg>] ...
`,
24 25
		ShortDescription: `
Basic commands:
26

Markus Amalthea Magnuson's avatar
Markus Amalthea Magnuson committed
27
    init          Initialize ipfs local configuration
28 29 30
    add <path>    Add an object to ipfs
    cat <ref>     Show ipfs object data
    ls <ref>      List links from an object
31 32 33

Tool commands:

34 35 36 37
    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
38
    id            Show info about ipfs peers
39 40 41

Advanced Commands:

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

Plumbing commands:

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

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

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

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

func init() {
91
	Root.Subcommands = rootSubcommands
92
}
93 94 95 96 97

type MessageOutput struct {
	Message string
}

98 99
func MessageTextMarshaler(res cmds.Response) (io.Reader, error) {
	return strings.NewReader(res.Output().(*MessageOutput).Message), nil
100
}