1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 01:52:26 +08:00

core/commands2: Use Argument constructors in commands

This commit is contained in:
Matt Bell
2014-11-11 15:55:20 -08:00
committed by Juan Batiz-Benet
parent 40e96a1fa6
commit c468a4dbf5
13 changed files with 23 additions and 41 deletions

View File

@ -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,

View File

@ -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.

View File

@ -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{
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

View File

@ -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{
` + 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())

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -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

View File

@ -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{
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:
(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>.
`, `,
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

View File

@ -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.
`, `,
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)"),

View File

@ -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")

View File

@ -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"),

View File

@ -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) {