From bcd25416d9a981d89d2ffa535da3604a6c4834e8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 20 Nov 2017 22:20:49 -0800 Subject: [PATCH] cmds: rename DefaultVal -> Default, Default -> WithDefault Propagate change from cmdkit. License: MIT Signed-off-by: Steven Allen --- cmd/ipfs/daemon.go | 6 +++--- cmd/ipfs/init.go | 2 +- commands/cli/helptext.go | 2 +- commands/request.go | 2 +- core/commands/add.go | 8 ++++---- core/commands/block.go | 6 +++--- core/commands/dag/dag.go | 6 +++--- core/commands/dht.go | 2 +- core/commands/files/files.go | 4 ++-- core/commands/get.go | 2 +- core/commands/ls.go | 2 +- core/commands/object/object.go | 4 ++-- core/commands/pin.go | 8 ++++---- core/commands/ping.go | 2 +- core/commands/publish.go | 6 +++--- core/commands/refs.go | 2 +- core/commands/stat.go | 2 +- 17 files changed, 33 insertions(+), 33 deletions(-) diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index b2a58cd5487..bc6c2d9d8aa 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -145,7 +145,7 @@ Headers. Options: []cmdkit.Option{ 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(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."), @@ -153,11 +153,11 @@ Headers. cmdkit.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"), cmdkit.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"), 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(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(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. // cmdkit.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"), diff --git a/cmd/ipfs/init.go b/cmd/ipfs/init.go index 08fb0d4217d..ed95a5225ba 100644 --- a/cmd/ipfs/init.go +++ b/cmd/ipfs/init.go @@ -50,7 +50,7 @@ environment variable: cmdkit.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(), }, 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.StringOption("profile", "p", "Apply profile settings to config. Multiple profiles can be separated by ','"), diff --git a/commands/cli/helptext.go b/commands/cli/helptext.go index 23cadc4f31e..84408417675 100644 --- a/commands/cli/helptext.go +++ b/commands/cli/helptext.go @@ -232,7 +232,7 @@ func generateSynopsis(cmd *cmds.Command, path string) string { if len(n) > 1 { pre = "--" } - if opt.Type() == cmdkit.Bool && opt.DefaultVal() == true { + if opt.Type() == cmdkit.Bool && opt.Default() == true { pre = "--" sopt = fmt.Sprintf("%s%s=false", pre, n) break diff --git a/commands/request.go b/commands/request.go index 517e8eb5efc..26c610526f7 100644 --- a/commands/request.go +++ b/commands/request.go @@ -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 diff --git a/core/commands/add.go b/core/commands/add.go index c5b1a6e65c2..5b52aa91f86 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -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(wrapOptionName, "w", "Wrap files with a directory object."), 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.BoolOption(pinOptionName, "Pin this object when adding.").Default(true), + cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"), + cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true), cmdkit.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"), cmdkit.BoolOption(noCopyOptionName, "Add the file using filestore. (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.StringOption(hashOptionName, "Hash function to use. Will set Cid version to 1 if used. (experimental)").Default("sha2-256"), + 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)").WithDefault("sha2-256"), }, PreRun: func(req cmds.Request) error { quiet, _, _ := req.Option(quietOptionName).Bool() diff --git a/core/commands/block.go b/core/commands/block.go index 50d9083f60f..8b986bf9359 100644 --- a/core/commands/block.go +++ b/core/commands/block.go @@ -127,9 +127,9 @@ It reads from stdin, and is a base58 encoded multihash. cmdkit.FileArg("data", true, false, "The data to be stored as an IPFS block.").EnableStdin(), }, Options: []cmdkit.Option{ - cmdkit.StringOption("format", "f", "cid format for blocks to be created with.").Default("v0"), - cmdkit.StringOption("mhtype", "multihash hash function").Default("sha2-256"), - cmdkit.IntOption("mhlen", "multihash hash length").Default(-1), + cmdkit.StringOption("format", "f", "cid format for blocks to be created with.").WithDefault("v0"), + cmdkit.StringOption("mhtype", "multihash hash function").WithDefault("sha2-256"), + cmdkit.IntOption("mhlen", "multihash hash length").WithDefault(-1), }, Run: func(req cmds.Request, res cmds.ResponseEmitter) { n, err := req.InvocContext().GetNode() diff --git a/core/commands/dag/dag.go b/core/commands/dag/dag.go index 4881a39ab26..a15ddd17ffa 100644 --- a/core/commands/dag/dag.go +++ b/core/commands/dag/dag.go @@ -59,10 +59,10 @@ into an object of the specified format. cmdkit.FileArg("object data", true, true, "The object to put").EnableStdin(), }, Options: []cmdkit.Option{ - cmdkit.StringOption("format", "f", "Format that the object will be added as.").Default("cbor"), - cmdkit.StringOption("input-enc", "Format that the input object will be.").Default("json"), + 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.").WithDefault("json"), 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) { n, err := req.InvocContext().GetNode() diff --git a/core/commands/dht.go b/core/commands/dht.go index 0dd18716615..c9c3940c2eb 100644 --- a/core/commands/dht.go +++ b/core/commands/dht.go @@ -140,7 +140,7 @@ var findProvidersDhtCmd = &cmds.Command{ }, Options: []cmdkit.Option{ 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) { n, err := req.InvocContext().GetNode() diff --git a/core/commands/files/files.go b/core/commands/files/files.go index 4e99111af94..d57e601c71f 100644 --- a/core/commands/files/files.go +++ b/core/commands/files/files.go @@ -46,7 +46,7 @@ operations. `, }, 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{ "read": FilesReadCmd, @@ -77,7 +77,7 @@ var FilesStatCmd = &cmds.Command{ }, Options: []cmdkit.Option{ cmdkit.StringOption("format", "Print statistics in given format. Allowed tokens: "+ - " . Conflicts with other format options.").Default( + " . Conflicts with other format options.").WithDefault( ` Size: CumulativeSize: diff --git a/core/commands/get.go b/core/commands/get.go index ca006bb305b..77a79830c5b 100644 --- a/core/commands/get.go +++ b/core/commands/get.go @@ -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.BoolOption("archive", "a", "Output a TAR archive."), 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 { _, err := getCompressOptions(req) diff --git a/core/commands/ls.go b/core/commands/ls.go index 7f1a3d9b0b5..e6ab1e67db7 100644 --- a/core/commands/ls.go +++ b/core/commands/ls.go @@ -54,7 +54,7 @@ The JSON output contains type information. }, Options: []cmdkit.Option{ 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) { nd, err := req.InvocContext().GetNode() diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 2fa38ae4f2f..046aea593a2 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -382,8 +382,8 @@ And then run: cmdkit.FileArg("data", true, false, "Data to be stored as a DAG object.").EnableStdin(), }, Options: []cmdkit.Option{ - cmdkit.StringOption("inputenc", "Encoding type of input data. One of: {\"protobuf\", \"json\"}.").Default("json"), - cmdkit.StringOption("datafieldenc", "Encoding type of the data field, either \"text\" or \"base64\".").Default("text"), + 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\".").WithDefault("text"), cmdkit.BoolOption("pin", "Pin this object when adding."), }, Run: func(req cmds.Request, res cmds.Response) { diff --git a/core/commands/pin.go b/core/commands/pin.go index 18927f9fa63..09f9011c747 100644 --- a/core/commands/pin.go +++ b/core/commands/pin.go @@ -54,7 +54,7 @@ var addPinCmd = &cmds.Command{ cmdkit.StringArg("ipfs-path", true, true, "Path to object(s) to be pinned.").EnableStdin(), }, 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"), }, 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(), }, 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{}, 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."), }, 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."), }, 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."), }, Options: []cmdkit.Option{ - cmdkit.BoolOption("unpin", "Remove the old pin.").Default(true), + cmdkit.BoolOption("unpin", "Remove the old pin.").WithDefault(true), }, Type: PinOutput{}, Run: func(req cmds.Request, res cmds.Response) { diff --git a/core/commands/ping.go b/core/commands/ping.go index 2d4a8794208..191b329b7ad 100644 --- a/core/commands/ping.go +++ b/core/commands/ping.go @@ -39,7 +39,7 @@ trip latency information. cmdkit.StringArg("peer ID", true, true, "ID of peer to be pinged.").EnableStdin(), }, 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{ cmds.Text: func(res cmds.Response) (io.Reader, error) { diff --git a/core/commands/publish.go b/core/commands/publish.go index 984db5bf998..802a25da653 100644 --- a/core/commands/publish.go +++ b/core/commands/publish.go @@ -65,13 +65,13 @@ Alternatively, publish an using a valid PeerID (as listed by cmdkit.StringArg("ipfs-path", true, false, "ipfs path of the object to be published.").EnableStdin(), }, 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", `Time duration that the record will be valid for. <> 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("key", "k", "Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. 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: <>.").WithDefault("self"), }, Run: func(req cmds.Request, res cmds.Response) { n, err := req.InvocContext().GetNode() diff --git a/core/commands/refs.go b/core/commands/refs.go index b6ee568a048..e8f6c1167c9 100644 --- a/core/commands/refs.go +++ b/core/commands/refs.go @@ -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(), }, Options: []cmdkit.Option{ - cmdkit.StringOption("format", "Emit edges with given format. Available tokens: .").Default(""), + cmdkit.StringOption("format", "Emit edges with given format. Available tokens: .").WithDefault(""), cmdkit.BoolOption("edges", "e", "Emit edge format: ` -> `."), cmdkit.BoolOption("unique", "u", "Omit duplicate refs from output."), cmdkit.BoolOption("recursive", "r", "Recursively list links of child nodes."), diff --git a/core/commands/stat.go b/core/commands/stat.go index ee33bd5f34c..1fb2e0e00a0 100644 --- a/core/commands/stat.go +++ b/core/commands/stat.go @@ -76,7 +76,7 @@ Example: 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: - "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) {