forked from ipfs/kubo
/
root.go
99 lines (81 loc) · 2.42 KB
/
root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package commands
import (
"io"
"strings"
cmds "github.com/jbenet/go-ipfs/commands"
u "github.com/jbenet/go-ipfs/util"
)
var log = u.Logger("core/commands")
type TestOutput struct {
Foo string
Bar int
}
var Root = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "global p2p merkle-dag filesystem",
Synopsis: `
ipfs [<flags>] <command> [<arg>] ...
`,
ShortDescription: `
Basic commands:
init Initialize ipfs local configuration
add <path> Add an object to ipfs
cat <ref> Show ipfs object data
ls <ref> List links from an object
Tool commands:
config Manage configuration
update Download and apply go-ipfs updates
version Show ipfs version information
commands List all available commands
id Show info about ipfs peers
Advanced Commands:
daemon Start a long-running daemon process
mount Mount an ipfs read-only mountpoint
serve Serve an interface to ipfs
diag Print diagnostics
Plumbing commands:
block Interact with raw blocks in the datastore
object Interact with raw dag nodes
Use 'ipfs <command> --help' to learn more about each command.
`,
},
Options: []cmds.Option{
cmds.StringOption("config", "c", "Path to the configuration file to use"),
cmds.BoolOption("debug", "D", "Operate in debug mode"),
cmds.BoolOption("help", "Show the full command help text"),
cmds.BoolOption("h", "Show a short version of the command help text"),
cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon"),
},
}
// commandsDaemonCmd is the "ipfs commands" command for daemon
var CommandsDaemonCmd = CommandsCmd(Root)
var rootSubcommands = map[string]*cmds.Command{
"add": AddCmd,
"block": BlockCmd,
"bootstrap": BootstrapCmd,
"cat": CatCmd,
"commands": CommandsDaemonCmd,
"config": ConfigCmd,
"diag": DiagCmd,
"id": IDCmd,
"log": LogCmd,
"ls": LsCmd,
"mount": MountCmd,
"name": NameCmd,
"object": ObjectCmd,
"pin": PinCmd,
"refs": RefsCmd,
"swarm": SwarmCmd,
"ping": PingCmd,
"update": UpdateCmd,
"version": VersionCmd,
}
func init() {
Root.Subcommands = rootSubcommands
}
type MessageOutput struct {
Message string
}
func MessageTextMarshaler(res cmds.Response) (io.Reader, error) {
return strings.NewReader(res.Output().(*MessageOutput).Message), nil
}