mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-28 08:47:42 +08:00
core/commands2: Use Argument constructors in commands
This commit is contained in:

committed by
Juan Batiz-Benet

parent
40e96a1fa6
commit
c468a4dbf5
@ -22,8 +22,7 @@ IPFS very quickly. To start, run:
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"number", cmds.ArgString, false, false,
|
||||
"The number of the topic you would like to tour"},
|
||||
cmds.StringArg("number", false, false, "The number of the topic you would like to tour"),
|
||||
},
|
||||
Subcommands: map[string]*cmds.Command{
|
||||
"list": cmdIpfsTourList,
|
||||
|
@ -26,7 +26,7 @@ var addCmd = &cmds.Command{
|
||||
cmds.BoolOption("recursive", "r", "Must be specified when adding directories"),
|
||||
},
|
||||
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.",
|
||||
Help: `Adds contents of <path> to ipfs. Use -r to add directories.
|
||||
|
@ -38,7 +38,7 @@ var blockGetCmd = &cmds.Command{
|
||||
It outputs to stdout, and <key> is a base58 encoded multihash.`,
|
||||
|
||||
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) {
|
||||
n := req.Context().Node
|
||||
@ -74,7 +74,7 @@ var blockPutCmd = &cmds.Command{
|
||||
It reads from stdin, and <key> is a base58 encoded multihash.`,
|
||||
|
||||
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) {
|
||||
n := req.Context().Node
|
||||
|
@ -39,7 +39,7 @@ in the bootstrap list).
|
||||
` + bootstrapSecurityWarning,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"peer", cmds.ArgString, true, true, peerOptionDesc},
|
||||
cmds.StringArg("peer", true, true, peerOptionDesc),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
input, err := bootstrapInputToPeers(req.Arguments())
|
||||
@ -79,7 +79,7 @@ var bootstrapRemoveCmd = &cmds.Command{
|
||||
` + bootstrapSecurityWarning,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"peer", cmds.ArgString, true, true, peerOptionDesc},
|
||||
cmds.StringArg("peer", true, true, peerOptionDesc),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
input, err := bootstrapInputToPeers(req.Arguments())
|
||||
|
@ -16,8 +16,7 @@ it contains.
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"ipfs-path", cmds.ArgString, true, true,
|
||||
"The path to the IPFS object(s) to be outputted"},
|
||||
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted"),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
node := req.Context().Node
|
||||
|
@ -31,10 +31,8 @@ var configCmd = &cmds.Command{
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"key", cmds.ArgString, true, false,
|
||||
"The key of the config entry (e.g. \"Addresses.API\")"},
|
||||
cmds.Argument{"value", cmds.ArgString, false, false,
|
||||
"The value to set the config entry to"},
|
||||
cmds.StringArg("key", true, false, "The key of the config entry (e.g. \"Addresses.API\")"),
|
||||
cmds.StringArg("value", false, false, "The value to set the config entry to"),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
args := req.Arguments()
|
||||
|
@ -14,10 +14,8 @@ output of a running daemon.
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"subsystem", cmds.ArgString, true, false,
|
||||
"the subsystem logging identifier. Use * for all subsystems."},
|
||||
cmds.Argument{"level", cmds.ArgString, true, false,
|
||||
"one of: debug, info, notice, warning, error, critical"},
|
||||
cmds.StringArg("subsystem", true, false, "the subsystem logging identifier. Use * for all subsystems."),
|
||||
cmds.StringArg("level", true, false, "one of: debug, info, notice, warning, error, critical"),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
args := req.Arguments()
|
||||
|
@ -31,8 +31,7 @@ it contains, with the following format:
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"ipfs-path", cmds.ArgString, false, true,
|
||||
"The path to the IPFS object(s) to list links from"},
|
||||
cmds.StringArg("ipfs-path", false, true, "The path to the IPFS object(s) to list links from"),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
node := req.Context().Node
|
||||
|
@ -44,8 +44,7 @@ output is the raw data of the object.
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"key", cmds.ArgString, true, false,
|
||||
"Key of the object to retrieve, in base58-encoded multihash format"},
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format"),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
n := req.Context().Node
|
||||
@ -65,8 +64,7 @@ var objectLinksCmd = &cmds.Command{
|
||||
It outputs to stdout, and <key> is a base58 encoded multihash.`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"key", cmds.ArgString, true, false,
|
||||
"Key of the object to retrieve, in base58-encoded multihash format"},
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format"),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
n := req.Context().Node
|
||||
@ -94,8 +92,7 @@ This command outputs data in the following encodings:
|
||||
(Specified by the "--encoding" or "-enc" flags)`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"key", cmds.ArgString, true, false,
|
||||
"Key of the object to retrieve\n(in base58-encoded multihash format)"},
|
||||
cmds.StringArg("key", true, false, "Key of the object to retrieve\n(in base58-encoded multihash format)"),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
n := req.Context().Node
|
||||
@ -146,10 +143,8 @@ Data should be in the format specified by <encoding>.
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"data", cmds.ArgFile, true, false,
|
||||
"Data to be stored as a DAG object\nMust be encoded as specified in <encoding>"},
|
||||
cmds.Argument{"encoding", cmds.ArgString, true, false,
|
||||
"Encoding type of <data>, either \"protobuf\" or \"json\""},
|
||||
cmds.FileArg("data", true, false, "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\""),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
n := req.Context().Node
|
||||
|
@ -25,8 +25,7 @@ on disk.
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"ipfs-path", cmds.ArgString, true, true,
|
||||
"Path to object(s) to be pinned"},
|
||||
cmds.StringArg("ipfs-path", true, true, "Path to object(s) to be pinned"),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s)"),
|
||||
@ -59,8 +58,7 @@ collected if needed.
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"ipfs-path", cmds.ArgString, true, true,
|
||||
"Path to object(s) to be unpinned"},
|
||||
cmds.StringArg("ipfs-path", true, true, "Path to object(s) to be unpinned"),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
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:
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"name", cmds.ArgString, false, false,
|
||||
"The IPNS name to publish to. Defaults to your node's peerID"},
|
||||
cmds.Argument{"ipfs-path", cmds.ArgString, true, false,
|
||||
"IPFS path of the obejct to be published at <name>"},
|
||||
cmds.StringArg("name", false, false, "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>"),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
log.Debug("Begin Publish")
|
||||
|
@ -25,8 +25,7 @@ hashes it contains, with the following format:
|
||||
Note: list all refs recursively with -r.`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"ipfs-path", cmds.ArgString, true, true,
|
||||
"Path to the object(s) to list refs from"},
|
||||
cmds.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from"),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("unique", "u", "Omit duplicate refs from output"),
|
||||
|
@ -28,8 +28,7 @@ Resolve te value of another name:
|
||||
`,
|
||||
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.Argument{"name", cmds.ArgString, false, false,
|
||||
"The IPNS name to resolve. Defaults to your node's peerID."},
|
||||
cmds.StringArg("name", false, false, "The IPNS name to resolve. Defaults to your node's peerID."),
|
||||
},
|
||||
Run: func(req cmds.Request) (interface{}, error) {
|
||||
|
||||
|
Reference in New Issue
Block a user