1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-10-17 03:35:02 +08:00

cmds: rename DefaultVal -> Default, Default -> WithDefault

Propagate change from cmdkit.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
Steven Allen
2017-11-20 22:20:49 -08:00
parent 76e1da02a8
commit bcd25416d9
17 changed files with 33 additions and 33 deletions

View File

@ -145,7 +145,7 @@ Headers.
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"), cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").Default("dht"), cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("dht"),
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"), cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"), cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
cmdkit.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."), cmdkit.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."),
@ -153,11 +153,11 @@ Headers.
cmdkit.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"), cmdkit.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
cmdkit.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"), cmdkit.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
cmdkit.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"), cmdkit.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
cmdkit.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").Default(true), cmdkit.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").WithDefault(true),
cmdkit.BoolOption(offlineKwd, "Run offline. Do not connect to the rest of the network but provide local API."), cmdkit.BoolOption(offlineKwd, "Run offline. Do not connect to the rest of the network but provide local API."),
cmdkit.BoolOption(migrateKwd, "If true, assume yes at the migrate prompt. If false, assume no."), cmdkit.BoolOption(migrateKwd, "If true, assume yes at the migrate prompt. If false, assume no."),
cmdkit.BoolOption(enableFloodSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."), cmdkit.BoolOption(enableFloodSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
cmdkit.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").Default(true), cmdkit.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").WithDefault(true),
// TODO: add way to override addresses. tricky part: updating the config if also --init. // TODO: add way to override addresses. tricky part: updating the config if also --init.
// cmdkit.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"), // cmdkit.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),

View File

@ -50,7 +50,7 @@ environment variable:
cmdkit.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(), cmdkit.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.IntOption("bits", "b", "Number of bits to use in the generated RSA private key.").Default(nBitsForKeypairDefault), cmdkit.IntOption("bits", "b", "Number of bits to use in the generated RSA private key.").WithDefault(nBitsForKeypairDefault),
cmdkit.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage."), cmdkit.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage."),
cmdkit.StringOption("profile", "p", "Apply profile settings to config. Multiple profiles can be separated by ','"), cmdkit.StringOption("profile", "p", "Apply profile settings to config. Multiple profiles can be separated by ','"),

View File

@ -232,7 +232,7 @@ func generateSynopsis(cmd *cmds.Command, path string) string {
if len(n) > 1 { if len(n) > 1 {
pre = "--" pre = "--"
} }
if opt.Type() == cmdkit.Bool && opt.DefaultVal() == true { if opt.Type() == cmdkit.Bool && opt.Default() == true {
pre = "--" pre = "--"
sopt = fmt.Sprintf("%s%s=false", pre, n) sopt = fmt.Sprintf("%s%s=false", pre, n)
break break

View File

@ -121,7 +121,7 @@ func (r *request) Option(name string) *cmdkit.OptionValue {
} }
} }
return &cmdkit.OptionValue{option.DefaultVal(), false, option} return &cmdkit.OptionValue{option.Default(), false, option}
} }
// Options returns a copy of the option map // Options returns a copy of the option map

View File

@ -112,13 +112,13 @@ You can now check what blocks have been created by:
cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."), cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."), cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."), cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").Default("size-262144"), cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").Default(true), cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
cmdkit.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"), cmdkit.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
cmdkit.BoolOption(noCopyOptionName, "Add the file using filestore. (experimental)"), cmdkit.BoolOption(noCopyOptionName, "Add the file using filestore. (experimental)"),
cmdkit.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"), cmdkit.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"),
cmdkit.IntOption(cidVersionOptionName, "Cid version. Non-zero value will change default of 'raw-leaves' to true. (experimental)").Default(0), cmdkit.IntOption(cidVersionOptionName, "Cid version. Non-zero value will change default of 'raw-leaves' to true. (experimental)").WithDefault(0),
cmdkit.StringOption(hashOptionName, "Hash function to use. Will set Cid version to 1 if used. (experimental)").Default("sha2-256"), cmdkit.StringOption(hashOptionName, "Hash function to use. Will set Cid version to 1 if used. (experimental)").WithDefault("sha2-256"),
}, },
PreRun: func(req cmds.Request) error { PreRun: func(req cmds.Request) error {
quiet, _, _ := req.Option(quietOptionName).Bool() quiet, _, _ := req.Option(quietOptionName).Bool()

View File

@ -127,9 +127,9 @@ It reads from stdin, and <key> is a base58 encoded multihash.
cmdkit.FileArg("data", true, false, "The data to be stored as an IPFS block.").EnableStdin(), cmdkit.FileArg("data", true, false, "The data to be stored as an IPFS block.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.StringOption("format", "f", "cid format for blocks to be created with.").Default("v0"), cmdkit.StringOption("format", "f", "cid format for blocks to be created with.").WithDefault("v0"),
cmdkit.StringOption("mhtype", "multihash hash function").Default("sha2-256"), cmdkit.StringOption("mhtype", "multihash hash function").WithDefault("sha2-256"),
cmdkit.IntOption("mhlen", "multihash hash length").Default(-1), cmdkit.IntOption("mhlen", "multihash hash length").WithDefault(-1),
}, },
Run: func(req cmds.Request, res cmds.ResponseEmitter) { Run: func(req cmds.Request, res cmds.ResponseEmitter) {
n, err := req.InvocContext().GetNode() n, err := req.InvocContext().GetNode()

View File

@ -59,10 +59,10 @@ into an object of the specified format.
cmdkit.FileArg("object data", true, true, "The object to put").EnableStdin(), cmdkit.FileArg("object data", true, true, "The object to put").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.StringOption("format", "f", "Format that the object will be added as.").Default("cbor"), cmdkit.StringOption("format", "f", "Format that the object will be added as.").WithDefault("cbor"),
cmdkit.StringOption("input-enc", "Format that the input object will be.").Default("json"), cmdkit.StringOption("input-enc", "Format that the input object will be.").WithDefault("json"),
cmdkit.BoolOption("pin", "Pin this object when adding."), cmdkit.BoolOption("pin", "Pin this object when adding."),
cmdkit.StringOption("hash", "Hash function to use").Default(""), cmdkit.StringOption("hash", "Hash function to use").WithDefault(""),
}, },
Run: func(req cmds.Request, res cmds.Response) { Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode() n, err := req.InvocContext().GetNode()

View File

@ -140,7 +140,7 @@ var findProvidersDhtCmd = &cmds.Command{
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption("verbose", "v", "Print extra information."), cmdkit.BoolOption("verbose", "v", "Print extra information."),
cmdkit.IntOption("num-providers", "n", "The number of providers to find.").Default(20), cmdkit.IntOption("num-providers", "n", "The number of providers to find.").WithDefault(20),
}, },
Run: func(req cmds.Request, res cmds.Response) { Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode() n, err := req.InvocContext().GetNode()

View File

@ -46,7 +46,7 @@ operations.
`, `,
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption("f", "flush", "Flush target and ancestors after write.").Default(true), cmdkit.BoolOption("f", "flush", "Flush target and ancestors after write.").WithDefault(true),
}, },
Subcommands: map[string]*cmds.Command{ Subcommands: map[string]*cmds.Command{
"read": FilesReadCmd, "read": FilesReadCmd,
@ -77,7 +77,7 @@ var FilesStatCmd = &cmds.Command{
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.StringOption("format", "Print statistics in given format. Allowed tokens: "+ cmdkit.StringOption("format", "Print statistics in given format. Allowed tokens: "+
"<hash> <size> <cumulsize> <type> <childs>. Conflicts with other format options.").Default( "<hash> <size> <cumulsize> <type> <childs>. Conflicts with other format options.").WithDefault(
`<hash> `<hash>
Size: <size> Size: <size>
CumulativeSize: <cumulsize> CumulativeSize: <cumulsize>

View File

@ -46,7 +46,7 @@ may also specify the level of compression by specifying '-l=<1-9>'.
cmdkit.StringOption("output", "o", "The path where the output should be stored."), cmdkit.StringOption("output", "o", "The path where the output should be stored."),
cmdkit.BoolOption("archive", "a", "Output a TAR archive."), cmdkit.BoolOption("archive", "a", "Output a TAR archive."),
cmdkit.BoolOption("compress", "C", "Compress the output with GZIP compression."), cmdkit.BoolOption("compress", "C", "Compress the output with GZIP compression."),
cmdkit.IntOption("compression-level", "l", "The level of compression (1-9).").Default(-1), cmdkit.IntOption("compression-level", "l", "The level of compression (1-9).").WithDefault(-1),
}, },
PreRun: func(req cmds.Request) error { PreRun: func(req cmds.Request) error {
_, err := getCompressOptions(req) _, err := getCompressOptions(req)

View File

@ -54,7 +54,7 @@ The JSON output contains type information.
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption("headers", "v", "Print table headers (Hash, Size, Name)."), cmdkit.BoolOption("headers", "v", "Print table headers (Hash, Size, Name)."),
cmdkit.BoolOption("resolve-type", "Resolve linked objects to find out their types.").Default(true), cmdkit.BoolOption("resolve-type", "Resolve linked objects to find out their types.").WithDefault(true),
}, },
Run: func(req cmds.Request, res cmds.Response) { Run: func(req cmds.Request, res cmds.Response) {
nd, err := req.InvocContext().GetNode() nd, err := req.InvocContext().GetNode()

View File

@ -382,8 +382,8 @@ And then run:
cmdkit.FileArg("data", true, false, "Data to be stored as a DAG object.").EnableStdin(), cmdkit.FileArg("data", true, false, "Data to be stored as a DAG object.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.StringOption("inputenc", "Encoding type of input data. One of: {\"protobuf\", \"json\"}.").Default("json"), cmdkit.StringOption("inputenc", "Encoding type of input data. One of: {\"protobuf\", \"json\"}.").WithDefault("json"),
cmdkit.StringOption("datafieldenc", "Encoding type of the data field, either \"text\" or \"base64\".").Default("text"), cmdkit.StringOption("datafieldenc", "Encoding type of the data field, either \"text\" or \"base64\".").WithDefault("text"),
cmdkit.BoolOption("pin", "Pin this object when adding."), cmdkit.BoolOption("pin", "Pin this object when adding."),
}, },
Run: func(req cmds.Request, res cmds.Response) { Run: func(req cmds.Request, res cmds.Response) {

View File

@ -54,7 +54,7 @@ var addPinCmd = &cmds.Command{
cmdkit.StringArg("ipfs-path", true, true, "Path to object(s) to be pinned.").EnableStdin(), cmdkit.StringArg("ipfs-path", true, true, "Path to object(s) to be pinned.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s).").Default(true), cmdkit.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s).").WithDefault(true),
cmdkit.BoolOption("progress", "Show progress"), cmdkit.BoolOption("progress", "Show progress"),
}, },
Type: AddPinOutput{}, Type: AddPinOutput{},
@ -181,7 +181,7 @@ collected if needed. (By default, recursively. Use -r=false for direct pins.)
cmdkit.StringArg("ipfs-path", true, true, "Path to object(s) to be unpinned.").EnableStdin(), cmdkit.StringArg("ipfs-path", true, true, "Path to object(s) to be unpinned.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s).").Default(true), cmdkit.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s).").WithDefault(true),
}, },
Type: PinOutput{}, Type: PinOutput{},
Run: func(req cmds.Request, res cmds.Response) { Run: func(req cmds.Request, res cmds.Response) {
@ -275,7 +275,7 @@ Example:
cmdkit.StringArg("ipfs-path", false, true, "Path to object(s) to be listed."), cmdkit.StringArg("ipfs-path", false, true, "Path to object(s) to be listed."),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").Default("all"), cmdkit.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").WithDefault("all"),
cmdkit.BoolOption("quiet", "q", "Write just hashes of objects."), cmdkit.BoolOption("quiet", "q", "Write just hashes of objects."),
}, },
Run: func(req cmds.Request, res cmds.Response) { Run: func(req cmds.Request, res cmds.Response) {
@ -358,7 +358,7 @@ new pin and removing the old one.
cmdkit.StringArg("to-path", true, false, "Path to new object to be pinned."), cmdkit.StringArg("to-path", true, false, "Path to new object to be pinned."),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption("unpin", "Remove the old pin.").Default(true), cmdkit.BoolOption("unpin", "Remove the old pin.").WithDefault(true),
}, },
Type: PinOutput{}, Type: PinOutput{},
Run: func(req cmds.Request, res cmds.Response) { Run: func(req cmds.Request, res cmds.Response) {

View File

@ -39,7 +39,7 @@ trip latency information.
cmdkit.StringArg("peer ID", true, true, "ID of peer to be pinged.").EnableStdin(), cmdkit.StringArg("peer ID", true, true, "ID of peer to be pinged.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.IntOption("count", "n", "Number of ping messages to send.").Default(10), cmdkit.IntOption("count", "n", "Number of ping messages to send.").WithDefault(10),
}, },
Marshalers: cmds.MarshalerMap{ Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) { cmds.Text: func(res cmds.Response) (io.Reader, error) {

View File

@ -65,13 +65,13 @@ Alternatively, publish an <ipfs-path> using a valid PeerID (as listed by
cmdkit.StringArg("ipfs-path", true, false, "ipfs path of the object to be published.").EnableStdin(), cmdkit.StringArg("ipfs-path", true, false, "ipfs path of the object to be published.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.BoolOption("resolve", "Resolve given path before publishing.").Default(true), cmdkit.BoolOption("resolve", "Resolve given path before publishing.").WithDefault(true),
cmdkit.StringOption("lifetime", "t", cmdkit.StringOption("lifetime", "t",
`Time duration that the record will be valid for. <<default>> `Time duration that the record will be valid for. <<default>>
This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are
"ns", "us" (or "µs"), "ms", "s", "m", "h".`).Default("24h"), "ns", "us" (or "µs"), "ms", "s", "m", "h".`).WithDefault("24h"),
cmdkit.StringOption("ttl", "Time duration this record should be cached for (caution: experimental)."), cmdkit.StringOption("ttl", "Time duration this record should be cached for (caution: experimental)."),
cmdkit.StringOption("key", "k", "Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: <<default>>.").Default("self"), cmdkit.StringOption("key", "k", "Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: <<default>>.").WithDefault("self"),
}, },
Run: func(req cmds.Request, res cmds.Response) { Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode() n, err := req.InvocContext().GetNode()

View File

@ -61,7 +61,7 @@ NOTE: List all references recursively by using the flag '-r'.
cmdkit.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from.").EnableStdin(), cmdkit.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from.").EnableStdin(),
}, },
Options: []cmdkit.Option{ Options: []cmdkit.Option{
cmdkit.StringOption("format", "Emit edges with given format. Available tokens: <src> <dst> <linkname>.").Default("<dst>"), cmdkit.StringOption("format", "Emit edges with given format. Available tokens: <src> <dst> <linkname>.").WithDefault("<dst>"),
cmdkit.BoolOption("edges", "e", "Emit edge format: `<from> -> <to>`."), cmdkit.BoolOption("edges", "e", "Emit edge format: `<from> -> <to>`."),
cmdkit.BoolOption("unique", "u", "Omit duplicate refs from output."), cmdkit.BoolOption("unique", "u", "Omit duplicate refs from output."),
cmdkit.BoolOption("recursive", "r", "Recursively list links of child nodes."), cmdkit.BoolOption("recursive", "r", "Recursively list links of child nodes."),

View File

@ -76,7 +76,7 @@ Example:
cmdkit.StringOption("interval", "i", `Time interval to wait between updating output, if 'poll' is true. cmdkit.StringOption("interval", "i", `Time interval to wait between updating output, if 'poll' is true.
This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are: This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are:
"ns", "us" (or "µs"), "ms", "s", "m", "h".`).Default("1s"), "ns", "us" (or "µs"), "ms", "s", "m", "h".`).WithDefault("1s"),
}, },
Run: func(req cmds.Request, res cmds.ResponseEmitter) { Run: func(req cmds.Request, res cmds.ResponseEmitter) {