root.go 2.9 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
		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 44 45
    name          Publish or resolve IPNS names
    pin           Pin objects to local storage
    gc            Garbage collect unpinned objects
46

47
NETWORK COMMANDS
48

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

56
TOOL COMMANDS
57

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

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

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

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

func init() {
104
	Root.Subcommands = rootSubcommands
105
}
106 107 108 109 110

type MessageOutput struct {
	Message string
}

111 112
func MessageTextMarshaler(res cmds.Response) (io.Reader, error) {
	return strings.NewReader(res.Output().(*MessageOutput).Message), nil
113
}