forked from ipfs/kubo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
root.go
113 lines (93 loc) · 2.9 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
get <ref> Download ipfs objects
ls <ref> List links from an object
refs <ref> List hashes of links from an object
DATA STRUCTURE COMMANDS
block Interact with raw blocks in the datastore
object Interact with raw dag nodes
ADVANCED COMMANDS
daemon Start a long-running daemon process
mount Mount an ipfs read-only mountpoint
name Publish or resolve IPNS names
pin Pin objects to local storage
gc Garbage collect unpinned objects
NETWORK COMMANDS
id Show info about ipfs peers
bootstrap Add or remove bootstrap peers
swarm Manage connections to the p2p network
dht Query the dht for values or peers
ping Measure the latency of a connection
diag Print diagnostics
TOOL COMMANDS
config Manage configuration
version Show ipfs version information
update Download and apply go-ipfs updates
commands List all available commands
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,
"dht": DhtCmd,
"diag": DiagCmd,
"get": GetCmd,
"id": IDCmd,
"log": LogCmd,
"ls": LsCmd,
"mount": MountCmd,
"name": NameCmd,
"object": ObjectCmd,
"pin": PinCmd,
"ping": PingCmd,
"refs": RefsCmd,
"repo": RepoCmd,
"swarm": SwarmCmd,
"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
}