提交 c468a4db 作者: Matt Bell 提交者: Juan Batiz-Benet

core/commands2: Use Argument constructors in commands

上级 40e96a1f
...@@ -22,8 +22,7 @@ IPFS very quickly. To start, run: ...@@ -22,8 +22,7 @@ IPFS very quickly. To start, run:
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"number", cmds.ArgString, false, false, cmds.StringArg("number", false, false, "The number of the topic you would like to tour"),
"The number of the topic you would like to tour"},
}, },
Subcommands: map[string]*cmds.Command{ Subcommands: map[string]*cmds.Command{
"list": cmdIpfsTourList, "list": cmdIpfsTourList,
......
...@@ -26,7 +26,7 @@ var addCmd = &cmds.Command{ ...@@ -26,7 +26,7 @@ var addCmd = &cmds.Command{
cmds.BoolOption("recursive", "r", "Must be specified when adding directories"), cmds.BoolOption("recursive", "r", "Must be specified when adding directories"),
}, },
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"file", cmds.ArgFile, true, true, "The path to a file to be added to IPFS"}, cmds.FileArg("file", true, true, "The path to a file to be added to IPFS"),
}, },
Description: "Add an object to ipfs.", Description: "Add an object to ipfs.",
Help: `Adds contents of <path> to ipfs. Use -r to add directories. Help: `Adds contents of <path> to ipfs. Use -r to add directories.
......
...@@ -38,7 +38,7 @@ var blockGetCmd = &cmds.Command{ ...@@ -38,7 +38,7 @@ var blockGetCmd = &cmds.Command{
It outputs to stdout, and <key> is a base58 encoded multihash.`, It outputs to stdout, and <key> is a base58 encoded multihash.`,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"key", cmds.ArgString, true, false, "The base58 multihash of an existing block to get"}, cmds.StringArg("key", true, false, "The base58 multihash of an existing block to get"),
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node n := req.Context().Node
...@@ -74,7 +74,7 @@ var blockPutCmd = &cmds.Command{ ...@@ -74,7 +74,7 @@ var blockPutCmd = &cmds.Command{
It reads from stdin, and <key> is a base58 encoded multihash.`, It reads from stdin, and <key> is a base58 encoded multihash.`,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"data", cmds.ArgFile, true, false, "The data to be stored as an IPFS block"}, cmds.FileArg("data", true, false, "The data to be stored as an IPFS block"),
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node n := req.Context().Node
......
...@@ -39,7 +39,7 @@ in the bootstrap list). ...@@ -39,7 +39,7 @@ in the bootstrap list).
` + bootstrapSecurityWarning, ` + bootstrapSecurityWarning,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"peer", cmds.ArgString, true, true, peerOptionDesc}, cmds.StringArg("peer", true, true, peerOptionDesc),
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
input, err := bootstrapInputToPeers(req.Arguments()) input, err := bootstrapInputToPeers(req.Arguments())
...@@ -79,7 +79,7 @@ var bootstrapRemoveCmd = &cmds.Command{ ...@@ -79,7 +79,7 @@ var bootstrapRemoveCmd = &cmds.Command{
` + bootstrapSecurityWarning, ` + bootstrapSecurityWarning,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"peer", cmds.ArgString, true, true, peerOptionDesc}, cmds.StringArg("peer", true, true, peerOptionDesc),
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
input, err := bootstrapInputToPeers(req.Arguments()) input, err := bootstrapInputToPeers(req.Arguments())
......
...@@ -16,8 +16,7 @@ it contains. ...@@ -16,8 +16,7 @@ it contains.
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"ipfs-path", cmds.ArgString, true, true, cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted"),
"The path to the IPFS object(s) to be outputted"},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
node := req.Context().Node node := req.Context().Node
......
...@@ -31,10 +31,8 @@ var configCmd = &cmds.Command{ ...@@ -31,10 +31,8 @@ var configCmd = &cmds.Command{
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"key", cmds.ArgString, true, false, cmds.StringArg("key", true, false, "The key of the config entry (e.g. \"Addresses.API\")"),
"The key of the config entry (e.g. \"Addresses.API\")"}, cmds.StringArg("value", false, false, "The value to set the config entry to"),
cmds.Argument{"value", cmds.ArgString, false, false,
"The value to set the config entry to"},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
args := req.Arguments() args := req.Arguments()
......
...@@ -14,10 +14,8 @@ output of a running daemon. ...@@ -14,10 +14,8 @@ output of a running daemon.
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"subsystem", cmds.ArgString, true, false, cmds.StringArg("subsystem", true, false, "the subsystem logging identifier. Use * for all subsystems."),
"the subsystem logging identifier. Use * for all subsystems."}, cmds.StringArg("level", true, false, "one of: debug, info, notice, warning, error, critical"),
cmds.Argument{"level", cmds.ArgString, true, false,
"one of: debug, info, notice, warning, error, critical"},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
args := req.Arguments() args := req.Arguments()
......
...@@ -31,8 +31,7 @@ it contains, with the following format: ...@@ -31,8 +31,7 @@ it contains, with the following format:
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"ipfs-path", cmds.ArgString, false, true, cmds.StringArg("ipfs-path", false, true, "The path to the IPFS object(s) to list links from"),
"The path to the IPFS object(s) to list links from"},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
node := req.Context().Node node := req.Context().Node
......
...@@ -44,8 +44,7 @@ output is the raw data of the object. ...@@ -44,8 +44,7 @@ output is the raw data of the object.
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"key", cmds.ArgString, true, false, cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format"),
"Key of the object to retrieve, in base58-encoded multihash format"},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node n := req.Context().Node
...@@ -65,8 +64,7 @@ var objectLinksCmd = &cmds.Command{ ...@@ -65,8 +64,7 @@ var objectLinksCmd = &cmds.Command{
It outputs to stdout, and <key> is a base58 encoded multihash.`, It outputs to stdout, and <key> is a base58 encoded multihash.`,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"key", cmds.ArgString, true, false, cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format"),
"Key of the object to retrieve, in base58-encoded multihash format"},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node n := req.Context().Node
...@@ -94,8 +92,7 @@ This command outputs data in the following encodings: ...@@ -94,8 +92,7 @@ This command outputs data in the following encodings:
(Specified by the "--encoding" or "-enc" flags)`, (Specified by the "--encoding" or "-enc" flags)`,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"key", cmds.ArgString, true, false, cmds.StringArg("key", true, false, "Key of the object to retrieve\n(in base58-encoded multihash format)"),
"Key of the object to retrieve\n(in base58-encoded multihash format)"},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node n := req.Context().Node
...@@ -146,10 +143,8 @@ Data should be in the format specified by <encoding>. ...@@ -146,10 +143,8 @@ Data should be in the format specified by <encoding>.
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"data", cmds.ArgFile, true, false, cmds.FileArg("data", true, false, "Data to be stored as a DAG object\nMust be encoded as specified in <encoding>"),
"Data to be stored as a DAG object\nMust be encoded as specified in <encoding>"}, cmds.StringArg("encoding", true, false, "Encoding type of <data>, either \"protobuf\" or \"json\""),
cmds.Argument{"encoding", cmds.ArgString, true, false,
"Encoding type of <data>, either \"protobuf\" or \"json\""},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node n := req.Context().Node
......
...@@ -25,8 +25,7 @@ on disk. ...@@ -25,8 +25,7 @@ on disk.
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"ipfs-path", cmds.ArgString, true, true, cmds.StringArg("ipfs-path", true, true, "Path to object(s) to be pinned"),
"Path to object(s) to be pinned"},
}, },
Options: []cmds.Option{ Options: []cmds.Option{
cmds.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s)"), cmds.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s)"),
...@@ -59,8 +58,7 @@ collected if needed. ...@@ -59,8 +58,7 @@ collected if needed.
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"ipfs-path", cmds.ArgString, true, true, cmds.StringArg("ipfs-path", true, true, "Path to object(s) to be unpinned"),
"Path to object(s) to be unpinned"},
}, },
Options: []cmds.Option{ Options: []cmds.Option{
cmds.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s)"), cmds.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s)"),
......
...@@ -34,10 +34,8 @@ Publish a <ref> to another public key: ...@@ -34,10 +34,8 @@ Publish a <ref> to another public key:
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"name", cmds.ArgString, false, false, cmds.StringArg("name", false, false, "The IPNS name to publish to. Defaults to your node's peerID"),
"The IPNS name to publish to. Defaults to your node's peerID"}, cmds.StringArg("ipfs-path", true, false, "IPFS path of the obejct to be published at <name>"),
cmds.Argument{"ipfs-path", cmds.ArgString, true, false,
"IPFS path of the obejct to be published at <name>"},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
log.Debug("Begin Publish") log.Debug("Begin Publish")
......
...@@ -25,8 +25,7 @@ hashes it contains, with the following format: ...@@ -25,8 +25,7 @@ hashes it contains, with the following format:
Note: list all refs recursively with -r.`, Note: list all refs recursively with -r.`,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"ipfs-path", cmds.ArgString, true, true, cmds.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from"),
"Path to the object(s) to list refs from"},
}, },
Options: []cmds.Option{ Options: []cmds.Option{
cmds.BoolOption("unique", "u", "Omit duplicate refs from output"), cmds.BoolOption("unique", "u", "Omit duplicate refs from output"),
......
...@@ -28,8 +28,7 @@ Resolve te value of another name: ...@@ -28,8 +28,7 @@ Resolve te value of another name:
`, `,
Arguments: []cmds.Argument{ Arguments: []cmds.Argument{
cmds.Argument{"name", cmds.ArgString, false, false, cmds.StringArg("name", false, false, "The IPNS name to resolve. Defaults to your node's peerID."),
"The IPNS name to resolve. Defaults to your node's peerID."},
}, },
Run: func(req cmds.Request) (interface{}, error) { Run: func(req cmds.Request) (interface{}, error) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论