core/commands: Ported commands to use HelpText struct for helptext fields
Matt Bell committed
Nov 12, 2014 at 22:37 UTC
7f24a9965f83d24361126de6a1db9382a13cbe41
9 files changed
+71
-34
core/commands2/add.go
+10
-6
@@ -29,18 +29,22 @@ type AddOutput struct {
29
}
30
31
var addCmd = &cmds.Command{
32
+ Helptext: cmds.HelpText{
33
+ Tagline: "Add an object to ipfs.",
34
+ ShortDescription: `
35
+Adds contents of <path> to ipfs. Use -r to add directories.
36
+Note that directories are added recursively, to form the ipfs
37
+MerkleDAG. A smarter partial add with a staging area (like git)
38
+remains to be implemented.
39
+`,
40
+ },
41
+
42
Options: []cmds.Option{
43
cmds.BoolOption("recursive", "r", "Must be specified when adding directories"),
44
},
45
Arguments: []cmds.Argument{
46
cmds.StringArg("file", true, true, "The path to a file to be added to IPFS"),
47
},
38
- Description: "Add an object to ipfs.",
39
- Help: `Adds contents of <path> to ipfs. Use -r to add directories.
40
-Note that directories are added recursively, to form the ipfs
41
-MerkleDAG. A smarter partial add with a staging area (like git)
42
-remains to be implemented.
43
-`,
48
Run: func(req cmds.Request) (interface{}, error) {
49
added := &AddOutput{}
50
n, err := req.Context().GetNode()
core/commands2/block.go
+15
-6
@@ -21,10 +21,15 @@ type Block struct {
21
}
22
23
var blockCmd = &cmds.Command{
24
- Description: "Manipulate raw IPFS blocks",
25
- Help: `'ipfs block' is a plumbing command used to manipulate raw ipfs blocks.
24
+ Helptext: cmds.HelpText{
25
+ Tagline: "Manipulate raw IPFS blocks",
26
+ ShortDescription: `
27
+'ipfs block' is a plumbing command used to manipulate raw ipfs blocks.
28
Reads from stdin or writes to stdout, and <key> is a base58 encoded
27
-multihash.`,
29
+multihash.
30
+`,
31
+ },
32
+
33
Subcommands: map[string]*cmds.Command{
34
"get": blockGetCmd,
35
"put": blockPutCmd,
@@ -32,9 +37,13 @@ multihash.`,
37
}
38
39
var blockGetCmd = &cmds.Command{
35
- Description: "Get a raw IPFS block",
36
- Help: `ipfs block get is a plumbing command for retreiving raw ipfs blocks.
37
-It outputs to stdout, and <key> is a base58 encoded multihash.`,
40
+ Helptext: cmds.HelpText{
41
+ Tagline: "Get a raw IPFS block",
42
+ ShortDescription: `
43
+'ipfs block get' is a plumbing command for retreiving raw ipfs blocks.
44
+It outputs to stdout, and <key> is a base58 encoded multihash.
45
+`,
46
+ },
47
48
Arguments: []cmds.Argument{
49
cmds.StringArg("key", true, false, "The base58 multihash of an existing block to get"),
core/commands2/bootstrap.go
+16
-9
@@ -19,9 +19,11 @@ type BootstrapOutput struct {
19
var peerOptionDesc = "A peer to add to the bootstrap list (in the format '<multiaddr>/<peerID>')"
20
21
var bootstrapCmd = &cmds.Command{
22
- Description: "Show or edit the list of bootstrap peers",
23
- Help: `Running 'ipfs bootstrap' with no arguments will run 'ipfs bootstrap list'.
22
+ Helptext: cmds.HelpText{
23
+ Tagline: "Show or edit the list of bootstrap peers",
24
+ ShortDescription: `Running 'ipfs bootstrap' with no arguments will run 'ipfs bootstrap list'.
25
` + bootstrapSecurityWarning,
26
+ },
27
28
Run: bootstrapListCmd.Run,
29
Marshallers: bootstrapListCmd.Marshallers,
@@ -35,10 +37,12 @@ var bootstrapCmd = &cmds.Command{
37
}
38
39
var bootstrapAddCmd = &cmds.Command{
38
- Description: "Add peers to the bootstrap list",
39
- Help: `Outputs a list of peers that were added (that weren't already
40
+ Helptext: cmds.HelpText{
41
+ Tagline: "Add peers to the bootstrap list",
42
+ ShortDescription: `Outputs a list of peers that were added (that weren't already
43
in the bootstrap list).
44
` + bootstrapSecurityWarning,
45
+ },
46
47
Arguments: []cmds.Argument{
48
cmds.StringArg("peer", true, true, peerOptionDesc),
@@ -81,9 +85,11 @@ in the bootstrap list).
85
}
86
87
var bootstrapRemoveCmd = &cmds.Command{
84
- Description: "Removes peers from the bootstrap list",
85
- Help: `Outputs the list of peers that were removed.
88
+ Helptext: cmds.HelpText{
89
+ Tagline: "Removes peers from the bootstrap list",
90
+ ShortDescription: `Outputs the list of peers that were removed.
91
` + bootstrapSecurityWarning,
92
+ },
93
94
Arguments: []cmds.Argument{
95
cmds.StringArg("peer", true, true, peerOptionDesc),
@@ -126,9 +132,10 @@ var bootstrapRemoveCmd = &cmds.Command{
132
}
133
134
var bootstrapListCmd = &cmds.Command{
129
- Description: "Show peers in the bootstrap list",
130
- Help: `Peers are output in the format '<multiaddr>/<peerID>'.
131
-`,
135
+ Helptext: cmds.HelpText{
136
+ Tagline: "Show peers in the bootstrap list",
137
+ ShortDescription: "Peers are output in the format '<multiaddr>/<peerID>'.",
138
+ },
139
140
Run: func(req cmds.Request) (interface{}, error) {
141
cfg, err := req.Context().GetConfig()
core/commands2/cat.go
+6
-3
@@ -10,10 +10,13 @@ import (
10
)
11
12
var catCmd = &cmds.Command{
13
- Description: "Show IPFS object data",
14
- Help: `Retrieves the object named by <ipfs-path> and outputs the data
13
+ Helptext: cmds.HelpText{
14
+ Tagline: "Show IPFS object data",
15
+ ShortDescription: `
16
+Retrieves the object named by <ipfs-path> and outputs the data
17
it contains.
16
- `,
18
+`,
19
+ },
20
21
Arguments: []cmds.Argument{
22
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted"),
core/commands2/diag.go
+5
-2
@@ -37,11 +37,14 @@ var diagCmd = &cmds.Command{
37
}
38
39
var diagNetCmd = &cmds.Command{
40
- Description: "Generates a network diagnostics report",
41
- Help: `Sends out a message to each node in the network recursively
40
+ Helptext: cmds.HelpText{
41
+ Tagline: "Generates a network diagnostics report",
42
+ ShortDescription: `
43
+Sends out a message to each node in the network recursively
44
requesting a listing of data about them including number of
45
connected peers and latencies between them.
46
`,
47
+ },
48
49
Run: func(req cmds.Request) (interface{}, error) {
50
n, err := req.Context().GetNode()
core/commands2/log.go
+5
-2
@@ -8,10 +8,13 @@ import (
8
)
9
10
var logCmd = &cmds.Command{
11
- Description: "Change the logging level",
12
- Help: `'ipfs log' is a utility command used to change the logging
11
+ Helptext: cmds.HelpText{
12
+ Tagline: "Change the logging level",
13
+ ShortDescription: `
14
+'ipfs log' is a utility command used to change the logging
15
output of a running daemon.
16
`,
17
+ },
18
19
Arguments: []cmds.Argument{
20
cmds.StringArg("subsystem", true, false, "the subsystem logging identifier. Use * for all subsystems."),
core/commands2/ls.go
+5
-2
@@ -23,12 +23,15 @@ type LsOutput struct {
23
}
24
25
var lsCmd = &cmds.Command{
26
- Description: "List links from an object.",
27
- Help: `Retrieves the object named by <ipfs-path> and displays the links
26
+ Helptext: cmds.HelpText{
27
+ Tagline: "List links from an object.",
28
+ ShortDescription: `
29
+Retrieves the object named by <ipfs-path> and displays the links
30
it contains, with the following format:
31
32
<link base58 hash> <link size in bytes> <link name>
33
`,
34
+ },
35
36
Arguments: []cmds.Argument{
37
cmds.StringArg("ipfs-path", false, true, "The path to the IPFS object(s) to list links from"),
core/commands2/mount_unix.go
+5
-2
@@ -18,11 +18,14 @@ import (
18
const mountTimeout = time.Second
19
20
var mountCmd = &cmds.Command{
21
- Description: "Mounts IPFS to the filesystem (read-only)",
22
- Help: `Mount ipfs at a read-only mountpoint on the OS. All ipfs objects
21
+ Helptext: cmds.HelpText{
22
+ Tagline: "Mounts IPFS to the filesystem (read-only)",
23
+ ShortDescription: `
24
+Mount ipfs at a read-only mountpoint on the OS. All ipfs objects
25
will be accessible under that directory. Note that the root will
26
not be listable, as it is virtual. Accessing known paths directly.
27
`,
28
+ },
29
30
Options: []cmds.Option{
31
// TODO longform
core/commands2/mount_windows.go
+4
-2
@@ -7,8 +7,10 @@ import (
7
)
8
9
var ipfsMount = &cmds.Command{
10
- Description: "Not yet implemented on Windows",
11
- Help: `Not yet implemented on Windows. :(`,
10
+ Helptext: cmds.HelpText{
11
+ Tagline: "Not yet implemented on Windows",
12
+ ShortDescription: "Not yet implemented on Windows. :(",
13
+ },
14
15
Run: func(req cmds.Request) (interface{}, error) {
16
return errors.New("Mount isn't compatible with Windows yet"), nil