@cryptotaxi247 / kubo / commits / 2dd6f2415

core/commands2: Refactored some commands to HelpText struct for helptext fields

Matt Bell committed Nov 12, 2014 at 20:40 UTC 2dd6f24157379c26732ccf1835b8a299a33c1217
8 files changed +94 -35
cmd/ipfs2/tour.go
+5 -2
@@ -13,13 +13,16 @@ import (
13 )
14
15 var cmdTour = &cmds.Command{
16 - Description: "An introduction to IPFS",
17 - Help: `This is a tour that takes you through various IPFS concepts,
16 + Helptext: cmds.HelpText{
17 + Tagline: "An introduction to IPFS",
18 + ShortDescription: `
19 +This is a tour that takes you through various IPFS concepts,
20 features, and tools to make sure you get up to speed with
21 IPFS very quickly. To start, run:
22
23 ipfs tour
24 `,
25 + },
26
27 Arguments: []cmds.Argument{
28 cmds.StringArg("number", false, false, "The number of the topic you would like to tour"),
core/commands2/name.go
+10 -2
@@ -8,8 +8,15 @@ type IpnsEntry struct {
8 }
9
10 var nameCmd = &cmds.Command{
11 - Description: "IPFS namespace (IPNS) tool",
12 - Help: `IPNS is a PKI namespace, where names are the hashes of public keys, and
11 + Helptext: cmds.HelpText{
12 + Tagline: "IPFS namespace (IPNS) tool",
13 + ShortDescription: `
14 +IPNS is a PKI namespace, where names are the hashes of public keys, and
15 +the private key enables publishing new (signed) values. In both publish
16 +and resolve, the default value of <name> is your own identity public key.
17 +`,
18 + LongDescription: `
19 +IPNS is a PKI namespace, where names are the hashes of public keys, and
20 the private key enables publishing new (signed) values. In both publish
21 and resolve, the default value of <name> is your own identity public key.
22
@@ -37,6 +44,7 @@ Resolve the value of another name:
44 QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
45
46 `,
47 + },
48
49 Subcommands: map[string]*cmds.Command{
50 "publish": publishCmd,
core/commands2/object.go
+35 -11
@@ -24,8 +24,10 @@ type Node struct {
24 }
25
26 var objectCmd = &cmds.Command{
27 - Description: "Interact with ipfs objects",
28 - Help: `'ipfs object' is a plumbing command used to manipulate DAG objects directly.`,
27 + Helptext: cmds.HelpText{
28 + Tagline: "Interact with ipfs objects",
29 + ShortDescription: "'ipfs object' is a plumbing command used to manipulate DAG objects directly.",
30 + },
31
32 Subcommands: map[string]*cmds.Command{
33 "data": objectDataCmd,
@@ -36,13 +38,16 @@ var objectCmd = &cmds.Command{
38 }
39
40 var objectDataCmd = &cmds.Command{
39 - Description: "Outputs the raw bytes in an IPFS object",
40 - Help: `ipfs data is a plumbing command for retreiving the raw bytes stored in a DAG node.
41 + Helptext: cmds.HelpText{
42 + Tagline: "Outputs the raw bytes in an IPFS object",
43 + ShortDescription: `
44 +ipfs data is a plumbing command for retreiving the raw bytes stored in a DAG node.
45 It outputs to stdout, and <key> is a base58 encoded multihash.
46
47 Note that the "--encoding" option does not affect the output, since the
48 output is the raw data of the object.
49 `,
50 + },
51
52 Arguments: []cmds.Argument{
53 cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format"),
@@ -63,9 +68,13 @@ output is the raw data of the object.
68 }
69
70 var objectLinksCmd = &cmds.Command{
66 - Description: "Outputs the links pointed to by the specified object",
67 - Help: `'ipfs block get' is a plumbing command for retreiving raw IPFS blocks.
68 -It outputs to stdout, and <key> is a base58 encoded multihash.`,
71 + Helptext: cmds.HelpText{
72 + Tagline: "Outputs the links pointed to by the specified object",
73 + ShortDescription: `
74 +'ipfs block get' is a plumbing command for retreiving raw IPFS blocks.
75 +It outputs to stdout, and <key> is a base58 encoded multihash.
76 +`,
77 + },
78
79 Arguments: []cmds.Argument{
80 cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format"),
@@ -87,8 +96,15 @@ It outputs to stdout, and <key> is a base58 encoded multihash.`,
96 }
97
98 var objectGetCmd = &cmds.Command{
90 - Description: "Get and serialize the DAG node named by <key>",
91 - Help: `'ipfs object get' is a plumbing command for retreiving DAG nodes.
99 + Helptext: cmds.HelpText{
100 + Tagline: "Get and serialize the DAG node named by <key>",
101 + ShortDescription: `
102 +'ipfs object get' is a plumbing command for retreiving DAG nodes.
103 +It serializes the DAG node to the format specified by the "--encoding" flag.
104 +It outputs to stdout, and <key> is a base58 encoded multihash.
105 +`,
106 + LongDescription: `
107 +'ipfs object get' is a plumbing command for retreiving DAG nodes.
108 It serializes the DAG node to the format specified by the "--encoding" flag.
109 It outputs to stdout, and <key> is a base58 encoded multihash.
110
@@ -97,6 +113,7 @@ This command outputs data in the following encodings:
113 * "json"
114 * "xml"
115 (Specified by the "--encoding" or "-enc" flags)`,
116 + },
117
118 Arguments: []cmds.Argument{
119 cmds.StringArg("key", true, false, "Key of the object to retrieve\n(in base58-encoded multihash format)"),
@@ -142,8 +159,14 @@ This command outputs data in the following encodings:
159 }
160
161 var objectPutCmd = &cmds.Command{
145 - Description: "Stores input as a DAG object, outputs its key",
146 - Help: `'ipfs object put' is a plumbing command for storing DAG nodes.
162 + Helptext: cmds.HelpText{
163 + Tagline: "Stores input as a DAG object, outputs its key",
164 + ShortDescription: `
165 +'ipfs object put' is a plumbing command for storing DAG nodes.
166 +It reads from stdin, and the output is a base58 encoded multihash.
167 +`,
168 + LongDescription: `
169 +'ipfs object put' is a plumbing command for storing DAG nodes.
170 It reads from stdin, and the output is a base58 encoded multihash.
171
172 Data should be in the format specified by <encoding>.
@@ -151,6 +174,7 @@ Data should be in the format specified by <encoding>.
174 * "protobuf"
175 * "json"
176 `,
177 + },
178
179 Arguments: []cmds.Argument{
180 cmds.FileArg("data", true, false, "Data to be stored as a DAG object\nMust be encoded as specified in <encoding>"),
core/commands2/pin.go
+10 -4
@@ -19,10 +19,13 @@ var pinCmd = &cmds.Command{
19 }
20
21 var addPinCmd = &cmds.Command{
22 - Description: "Pins objects to local storage",
23 - Help: `Retrieves the object named by <ipfs-path> and stores it locally
22 + Helptext: cmds.HelpText{
23 + Tagline: "Pins objects to local storage",
24 + ShortDescription: `
25 +Retrieves the object named by <ipfs-path> and stores it locally
26 on disk.
27 `,
28 + },
29
30 Arguments: []cmds.Argument{
31 cmds.StringArg("ipfs-path", true, true, "Path to object(s) to be pinned"),
@@ -61,10 +64,13 @@ on disk.
64 }
65
66 var rmPinCmd = &cmds.Command{
64 - Description: "Unpin an object from local storage",
65 - Help: `Removes the pin from the given object allowing it to be garbage
67 + Helptext: cmds.HelpText{
68 + Tagline: "Unpin an object from local storage",
69 + ShortDescription: `
70 +Removes the pin from the given object allowing it to be garbage
71 collected if needed.
72 `,
73 + },
74
75 Arguments: []cmds.Argument{
76 cmds.StringArg("ipfs-path", true, true, "Path to object(s) to be unpinned"),
core/commands2/refs.go
+7 -3
@@ -16,13 +16,17 @@ type RefsOutput struct {
16 }
17
18 var refsCmd = &cmds.Command{
19 - Description: "Lists link hashes from an object",
20 - Help: `Retrieves the object named by <ipfs-path> and displays the link
19 + Helptext: cmds.HelpText{
20 + Tagline: "Lists link hashes from an object",
21 + ShortDescription: `
22 +Retrieves the object named by <ipfs-path> and displays the link
23 hashes it contains, with the following format:
24
25 <link base58 hash>
26
25 -Note: list all refs recursively with -r.`,
27 +Note: list all refs recursively with -r.
28 +`,
29 + },
30
31 Arguments: []cmds.Argument{
32 cmds.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from"),
core/commands2/resolve.go
+10 -2
@@ -8,8 +8,15 @@ import (
8 )
9
10 var resolveCmd = &cmds.Command{
11 - Description: "Gets the value currently published at an IPNS name",
12 - Help: `IPNS is a PKI namespace, where names are the hashes of public keys, and
11 + Helptext: cmds.HelpText{
12 + Tagline: "Gets the value currently published at an IPNS name",
13 + ShortDescription: `
14 +IPNS is a PKI namespace, where names are the hashes of public keys, and
15 +the private key enables publishing new (signed) values. In resolve, the
16 +default value of <name> is your own identity public key.
17 +`,
18 + LongDescription: `
19 +IPNS is a PKI namespace, where names are the hashes of public keys, and
20 the private key enables publishing new (signed) values. In resolve, the
21 default value of <name> is your own identity public key.
22
@@ -27,6 +34,7 @@ Resolve te value of another name:
34 QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
35
36 `,
37 + },
38
39 Arguments: []cmds.Argument{
40 cmds.StringArg("name", false, false, "The IPNS name to resolve. Defaults to your node's peerID."),
core/commands2/update.go
+13 -8
@@ -15,9 +15,10 @@ type UpdateOutput struct {
15 }
16
17 var updateCmd = &cmds.Command{
18 - Description: "Downloads and installs updates for IPFS",
19 - Help: `ipfs update is a utility command used to check for updates and apply them.
20 -`,
18 + Helptext: cmds.HelpText{
19 + Tagline: "Downloads and installs updates for IPFS",
20 + ShortDescription: "ipfs update is a utility command used to check for updates and apply them.",
21 + },
22
23 Run: func(req cmds.Request) (interface{}, error) {
24 n, err := req.Context().GetNode()
@@ -47,11 +48,14 @@ var updateCmd = &cmds.Command{
48 }
49
50 var updateCheckCmd = &cmds.Command{
50 - Description: "Checks if updates are available",
51 - Help: `'ipfs update check' checks if any updates are available for IPFS.
51 + Helptext: cmds.HelpText{
52 + Tagline: "Checks if updates are available",
53 + ShortDescription: `
54 +'ipfs update check' checks if any updates are available for IPFS.
55
56 Nothing will be downloaded or installed.
57 `,
58 + },
59
60 Run: func(req cmds.Request) (interface{}, error) {
61 n, err := req.Context().GetNode()
@@ -77,9 +81,10 @@ Nothing will be downloaded or installed.
81 }
82
83 var updateLogCmd = &cmds.Command{
80 - Description: "List the changelog for the latest versions of IPFS",
81 - Help: `This command is not yet implemented.
82 -`,
84 + Helptext: cmds.HelpText{
85 + Tagline: "List the changelog for the latest versions of IPFS",
86 + ShortDescription: "This command is not yet implemented.",
87 + },
88
89 Run: func(req cmds.Request) (interface{}, error) {
90 n, err := req.Context().GetNode()
core/commands2/version.go
+4 -3
@@ -10,9 +10,10 @@ type VersionOutput struct {
10 }
11
12 var versionCmd = &cmds.Command{
13 - Description: "Outputs the current version of IPFS",
14 - Help: `Returns the version number of IPFS and exits.
15 -`,
13 + Helptext: cmds.HelpText{
14 + Tagline: "Outputs the current version of IPFS",
15 + ShortDescription: "Returns the version number of IPFS and exits.",
16 + },
17
18 Options: []cmds.Option{
19 cmds.BoolOption("number", "n", "Only output the version number"),