@cryptotaxi247 / kubo / commits / c468a4dbf

core/commands2: Use Argument constructors in commands

Matt Bell committed Nov 11, 2014 at 15:55 UTC c468a4dbf5cc442713ed0eda5057bfdd8b8c74f9
13 files changed +23 -41
cmd/ipfs2/tour.go
+1 -2
@@ -22,8 +22,7 @@ IPFS very quickly. To start, run:
22 `,
23
24 Arguments: []cmds.Argument{
25 - cmds.Argument{"number", cmds.ArgString, false, false,
26 - "The number of the topic you would like to tour"},
25 + cmds.StringArg("number", false, false, "The number of the topic you would like to tour"),
26 },
27 Subcommands: map[string]*cmds.Command{
28 "list": cmdIpfsTourList,
core/commands2/add.go
+1 -1
@@ -26,7 +26,7 @@ var addCmd = &cmds.Command{
26 cmds.BoolOption("recursive", "r", "Must be specified when adding directories"),
27 },
28 Arguments: []cmds.Argument{
29 - cmds.Argument{"file", cmds.ArgFile, true, true, "The path to a file to be added to IPFS"},
29 + cmds.FileArg("file", true, true, "The path to a file to be added to IPFS"),
30 },
31 Description: "Add an object to ipfs.",
32 Help: `Adds contents of <path> to ipfs. Use -r to add directories.
core/commands2/block.go
+2 -2
@@ -38,7 +38,7 @@ var blockGetCmd = &cmds.Command{
38 It outputs to stdout, and <key> is a base58 encoded multihash.`,
39
40 Arguments: []cmds.Argument{
41 - cmds.Argument{"key", cmds.ArgString, true, false, "The base58 multihash of an existing block to get"},
41 + cmds.StringArg("key", true, false, "The base58 multihash of an existing block to get"),
42 },
43 Run: func(req cmds.Request) (interface{}, error) {
44 n := req.Context().Node
@@ -74,7 +74,7 @@ var blockPutCmd = &cmds.Command{
74 It reads from stdin, and <key> is a base58 encoded multihash.`,
75
76 Arguments: []cmds.Argument{
77 - cmds.Argument{"data", cmds.ArgFile, true, false, "The data to be stored as an IPFS block"},
77 + cmds.FileArg("data", true, false, "The data to be stored as an IPFS block"),
78 },
79 Run: func(req cmds.Request) (interface{}, error) {
80 n := req.Context().Node
core/commands2/bootstrap.go
+2 -2
@@ -39,7 +39,7 @@ in the bootstrap list).
39 ` + bootstrapSecurityWarning,
40
41 Arguments: []cmds.Argument{
42 - cmds.Argument{"peer", cmds.ArgString, true, true, peerOptionDesc},
42 + cmds.StringArg("peer", true, true, peerOptionDesc),
43 },
44 Run: func(req cmds.Request) (interface{}, error) {
45 input, err := bootstrapInputToPeers(req.Arguments())
@@ -79,7 +79,7 @@ var bootstrapRemoveCmd = &cmds.Command{
79 ` + bootstrapSecurityWarning,
80
81 Arguments: []cmds.Argument{
82 - cmds.Argument{"peer", cmds.ArgString, true, true, peerOptionDesc},
82 + cmds.StringArg("peer", true, true, peerOptionDesc),
83 },
84 Run: func(req cmds.Request) (interface{}, error) {
85 input, err := bootstrapInputToPeers(req.Arguments())
core/commands2/cat.go
+1 -2
@@ -16,8 +16,7 @@ it contains.
16 `,
17
18 Arguments: []cmds.Argument{
19 - cmds.Argument{"ipfs-path", cmds.ArgString, true, true,
20 - "The path to the IPFS object(s) to be outputted"},
19 + cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted"),
20 },
21 Run: func(req cmds.Request) (interface{}, error) {
22 node := req.Context().Node
core/commands2/config.go
+2 -4
@@ -31,10 +31,8 @@ var configCmd = &cmds.Command{
31 `,
32
33 Arguments: []cmds.Argument{
34 - cmds.Argument{"key", cmds.ArgString, true, false,
35 - "The key of the config entry (e.g. \"Addresses.API\")"},
36 - cmds.Argument{"value", cmds.ArgString, false, false,
37 - "The value to set the config entry to"},
34 + cmds.StringArg("key", true, false, "The key of the config entry (e.g. \"Addresses.API\")"),
35 + cmds.StringArg("value", false, false, "The value to set the config entry to"),
36 },
37 Run: func(req cmds.Request) (interface{}, error) {
38 args := req.Arguments()
core/commands2/log.go
+2 -4
@@ -14,10 +14,8 @@ output of a running daemon.
14 `,
15
16 Arguments: []cmds.Argument{
17 - cmds.Argument{"subsystem", cmds.ArgString, true, false,
18 - "the subsystem logging identifier. Use * for all subsystems."},
19 - cmds.Argument{"level", cmds.ArgString, true, false,
20 - "one of: debug, info, notice, warning, error, critical"},
17 + cmds.StringArg("subsystem", true, false, "the subsystem logging identifier. Use * for all subsystems."),
18 + cmds.StringArg("level", true, false, "one of: debug, info, notice, warning, error, critical"),
19 },
20 Run: func(req cmds.Request) (interface{}, error) {
21 args := req.Arguments()
core/commands2/ls.go
+1 -2
@@ -31,8 +31,7 @@ it contains, with the following format:
31 `,
32
33 Arguments: []cmds.Argument{
34 - cmds.Argument{"ipfs-path", cmds.ArgString, false, true,
35 - "The path to the IPFS object(s) to list links from"},
34 + cmds.StringArg("ipfs-path", false, true, "The path to the IPFS object(s) to list links from"),
35 },
36 Run: func(req cmds.Request) (interface{}, error) {
37 node := req.Context().Node
core/commands2/object.go
+5 -10
@@ -44,8 +44,7 @@ output is the raw data of the object.
44 `,
45
46 Arguments: []cmds.Argument{
47 - cmds.Argument{"key", cmds.ArgString, true, false,
48 - "Key of the object to retrieve, in base58-encoded multihash format"},
47 + cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format"),
48 },
49 Run: func(req cmds.Request) (interface{}, error) {
50 n := req.Context().Node
@@ -65,8 +64,7 @@ var objectLinksCmd = &cmds.Command{
64 It outputs to stdout, and <key> is a base58 encoded multihash.`,
65
66 Arguments: []cmds.Argument{
68 - cmds.Argument{"key", cmds.ArgString, true, false,
69 - "Key of the object to retrieve, in base58-encoded multihash format"},
67 + cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format"),
68 },
69 Run: func(req cmds.Request) (interface{}, error) {
70 n := req.Context().Node
@@ -94,8 +92,7 @@ This command outputs data in the following encodings:
92 (Specified by the "--encoding" or "-enc" flags)`,
93
94 Arguments: []cmds.Argument{
97 - cmds.Argument{"key", cmds.ArgString, true, false,
98 - "Key of the object to retrieve\n(in base58-encoded multihash format)"},
95 + cmds.StringArg("key", true, false, "Key of the object to retrieve\n(in base58-encoded multihash format)"),
96 },
97 Run: func(req cmds.Request) (interface{}, error) {
98 n := req.Context().Node
@@ -146,10 +143,8 @@ Data should be in the format specified by <encoding>.
143 `,
144
145 Arguments: []cmds.Argument{
149 - cmds.Argument{"data", cmds.ArgFile, true, false,
150 - "Data to be stored as a DAG object\nMust be encoded as specified in <encoding>"},
151 - cmds.Argument{"encoding", cmds.ArgString, true, false,
152 - "Encoding type of <data>, either \"protobuf\" or \"json\""},
146 + cmds.FileArg("data", true, false, "Data to be stored as a DAG object\nMust be encoded as specified in <encoding>"),
147 + cmds.StringArg("encoding", true, false, "Encoding type of <data>, either \"protobuf\" or \"json\""),
148 },
149 Run: func(req cmds.Request) (interface{}, error) {
150 n := req.Context().Node
core/commands2/pin.go
+2 -4
@@ -25,8 +25,7 @@ on disk.
25 `,
26
27 Arguments: []cmds.Argument{
28 - cmds.Argument{"ipfs-path", cmds.ArgString, true, true,
29 - "Path to object(s) to be pinned"},
28 + cmds.StringArg("ipfs-path", true, true, "Path to object(s) to be pinned"),
29 },
30 Options: []cmds.Option{
31 cmds.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s)"),
@@ -59,8 +58,7 @@ collected if needed.
58 `,
59
60 Arguments: []cmds.Argument{
62 - cmds.Argument{"ipfs-path", cmds.ArgString, true, true,
63 - "Path to object(s) to be unpinned"},
61 + cmds.StringArg("ipfs-path", true, true, "Path to object(s) to be unpinned"),
62 },
63 Options: []cmds.Option{
64 cmds.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s)"),
core/commands2/publish.go
+2 -4
@@ -34,10 +34,8 @@ Publish a <ref> to another public key:
34 `,
35
36 Arguments: []cmds.Argument{
37 - cmds.Argument{"name", cmds.ArgString, false, false,
38 - "The IPNS name to publish to. Defaults to your node's peerID"},
39 - cmds.Argument{"ipfs-path", cmds.ArgString, true, false,
40 - "IPFS path of the obejct to be published at <name>"},
37 + cmds.StringArg("name", false, false, "The IPNS name to publish to. Defaults to your node's peerID"),
38 + cmds.StringArg("ipfs-path", true, false, "IPFS path of the obejct to be published at <name>"),
39 },
40 Run: func(req cmds.Request) (interface{}, error) {
41 log.Debug("Begin Publish")
core/commands2/refs.go
+1 -2
@@ -25,8 +25,7 @@ hashes it contains, with the following format:
25 Note: list all refs recursively with -r.`,
26
27 Arguments: []cmds.Argument{
28 - cmds.Argument{"ipfs-path", cmds.ArgString, true, true,
29 - "Path to the object(s) to list refs from"},
28 + cmds.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from"),
29 },
30 Options: []cmds.Option{
31 cmds.BoolOption("unique", "u", "Omit duplicate refs from output"),
core/commands2/resolve.go
+1 -2
@@ -28,8 +28,7 @@ Resolve te value of another name:
28 `,
29
30 Arguments: []cmds.Argument{
31 - cmds.Argument{"name", cmds.ArgString, false, false,
32 - "The IPNS name to resolve. Defaults to your node's peerID."},
31 + cmds.StringArg("name", false, false, "The IPNS name to resolve. Defaults to your node's peerID."),
32 },
33 Run: func(req cmds.Request) (interface{}, error) {
34