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

import (
4 5 6
	"io"
	"strings"

7 8
	cmds "github.com/ipfs/go-ipfs/commands"
	evlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
9 10
)

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

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
		ShortDescription: `
25
BASIC COMMANDS
26

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

34
DATA STRUCTURE COMMANDS
35

36 37
    block         Interact with raw blocks in the datastore
    object        Interact with raw dag nodes
38

39
ADVANCED COMMANDS
40

41
    daemon        Start a long-running daemon process
42
    mount         Mount an ipfs read-only mountpoint
43
    name          Publish or resolve IPNS names
44
    dns           Resolve DNS links
45
    pin           Pin objects to local storage
46
    repo gc       Garbage collect unpinned objects
47

48
NETWORK COMMANDS
49

50
    id            Show info about ipfs peers
51
    bootstrap     Add or remove bootstrap peers
52 53
    swarm         Manage connections to the p2p network
    dht           Query the dht for values or peers
54
    ping          Measure the latency of a connection
55
    diag          Print diagnostics
56

57
TOOL COMMANDS
58

59 60 61 62
    config        Manage configuration
    version       Show ipfs version information
    update        Download and apply go-ipfs updates
    commands      List all available commands
63 64

Use 'ipfs <command> --help' to learn more about each command.
65
`,
66
	},
67
	Options: []cmds.Option{
68 69
		cmds.StringOption("config", "c", "Path to the configuration file to use"),
		cmds.BoolOption("debug", "D", "Operate in debug mode"),
70 71
		cmds.BoolOption("help", "Show the full command help text"),
		cmds.BoolOption("h", "Show a short version of the command help text"),
72
		cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon"),
73
	},
74 75
}

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

79
var rootSubcommands = map[string]*cmds.Command{
80 81 82 83
	"add":       AddCmd,
	"block":     BlockCmd,
	"bootstrap": BootstrapCmd,
	"cat":       CatCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
84
	"commands":  CommandsDaemonCmd,
85
	"config":    ConfigCmd,
86
	"dht":       DhtCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
87
	"diag":      DiagCmd,
88
	"dns":       DNSCmd,
Matt Bell's avatar
Matt Bell committed
89
	"get":       GetCmd,
90 91 92 93 94 95 96
	"id":        IDCmd,
	"log":       LogCmd,
	"ls":        LsCmd,
	"mount":     MountCmd,
	"name":      NameCmd,
	"object":    ObjectCmd,
	"pin":       PinCmd,
97
	"ping":      PingCmd,
98
	"refs":      RefsCmd,
Jeromy's avatar
Jeromy committed
99
	"repo":      RepoCmd,
Jeromy's avatar
Jeromy committed
100
	"stats":     StatsCmd,
101
	"swarm":     SwarmCmd,
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
102
	"update":    UpdateCmd,
103
	"version":   VersionCmd,
104
	"bitswap":   BitswapCmd,
105
}
106 107

func init() {
108
	Root.Subcommands = rootSubcommands
109
}
110 111 112 113 114

type MessageOutput struct {
	Message string
}

115 116
func MessageTextMarshaler(res cmds.Response) (io.Reader, error) {
	return strings.NewReader(res.Output().(*MessageOutput).Message), nil
117
}