root.go 3.09 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
    resolve       Resolve any type of name
44
    name          Publish or resolve IPNS names
45
    dns           Resolve DNS links
46
    pin           Pin objects to local storage
47
    repo gc       Garbage collect unpinned objects
48

49
NETWORK COMMANDS
50

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

58
TOOL COMMANDS
59

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

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

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

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

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

type MessageOutput struct {
	Message string
}

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