cmds: rename DefaultVal -> Default, Default -> WithDefault
Propagate change from cmdkit. License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Nov 20, 2017 at 22:20 UTC
bcd25416d9a981d89d2ffa535da3604a6c4834e8
17 files changed
+33
-33
cmd/ipfs/daemon.go
+3
-3
@@ -145,7 +145,7 @@ Headers.
145
146
Options: []cmdkit.Option{
147
cmdkit.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
148
- cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").Default("dht"),
148
+ cmdkit.StringOption(routingOptionKwd, "Overrides the routing option").WithDefault("dht"),
149
cmdkit.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
150
cmdkit.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
151
cmdkit.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."),
@@ -153,11 +153,11 @@ Headers.
153
cmdkit.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
154
cmdkit.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
155
cmdkit.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
156
- cmdkit.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").Default(true),
156
+ cmdkit.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").WithDefault(true),
157
cmdkit.BoolOption(offlineKwd, "Run offline. Do not connect to the rest of the network but provide local API."),
158
cmdkit.BoolOption(migrateKwd, "If true, assume yes at the migrate prompt. If false, assume no."),
159
cmdkit.BoolOption(enableFloodSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
160
- cmdkit.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").Default(true),
160
+ cmdkit.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").WithDefault(true),
161
162
// TODO: add way to override addresses. tricky part: updating the config if also --init.
163
// cmdkit.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
cmd/ipfs/init.go
+1
-1
@@ -50,7 +50,7 @@ environment variable:
50
cmdkit.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(),
51
},
52
Options: []cmdkit.Option{
53
- cmdkit.IntOption("bits", "b", "Number of bits to use in the generated RSA private key.").Default(nBitsForKeypairDefault),
53
+ cmdkit.IntOption("bits", "b", "Number of bits to use in the generated RSA private key.").WithDefault(nBitsForKeypairDefault),
54
cmdkit.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage."),
55
cmdkit.StringOption("profile", "p", "Apply profile settings to config. Multiple profiles can be separated by ','"),
56
commands/cli/helptext.go
+1
-1
@@ -232,7 +232,7 @@ func generateSynopsis(cmd *cmds.Command, path string) string {
232
if len(n) > 1 {
233
pre = "--"
234
}
235
- if opt.Type() == cmdkit.Bool && opt.DefaultVal() == true {
235
+ if opt.Type() == cmdkit.Bool && opt.Default() == true {
236
pre = "--"
237
sopt = fmt.Sprintf("%s%s=false", pre, n)
238
break
commands/request.go
+1
-1
@@ -121,7 +121,7 @@ func (r *request) Option(name string) *cmdkit.OptionValue {
121
}
122
}
123
124
- return &cmdkit.OptionValue{option.DefaultVal(), false, option}
124
+ return &cmdkit.OptionValue{option.Default(), false, option}
125
}
126
127
// Options returns a copy of the option map
core/commands/add.go
+4
-4
@@ -112,13 +112,13 @@ You can now check what blocks have been created by:
112
cmdkit.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
113
cmdkit.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
114
cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
115
- cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").Default("size-262144"),
116
- cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").Default(true),
115
+ cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
116
+ cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
117
cmdkit.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
118
cmdkit.BoolOption(noCopyOptionName, "Add the file using filestore. (experimental)"),
119
cmdkit.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"),
120
- cmdkit.IntOption(cidVersionOptionName, "Cid version. Non-zero value will change default of 'raw-leaves' to true. (experimental)").Default(0),
121
- cmdkit.StringOption(hashOptionName, "Hash function to use. Will set Cid version to 1 if used. (experimental)").Default("sha2-256"),
120
+ cmdkit.IntOption(cidVersionOptionName, "Cid version. Non-zero value will change default of 'raw-leaves' to true. (experimental)").WithDefault(0),
121
+ cmdkit.StringOption(hashOptionName, "Hash function to use. Will set Cid version to 1 if used. (experimental)").WithDefault("sha2-256"),
122
},
123
PreRun: func(req cmds.Request) error {
124
quiet, _, _ := req.Option(quietOptionName).Bool()
core/commands/block.go
+3
-3
@@ -127,9 +127,9 @@ It reads from stdin, and <key> is a base58 encoded multihash.
127
cmdkit.FileArg("data", true, false, "The data to be stored as an IPFS block.").EnableStdin(),
128
},
129
Options: []cmdkit.Option{
130
- cmdkit.StringOption("format", "f", "cid format for blocks to be created with.").Default("v0"),
131
- cmdkit.StringOption("mhtype", "multihash hash function").Default("sha2-256"),
132
- cmdkit.IntOption("mhlen", "multihash hash length").Default(-1),
130
+ cmdkit.StringOption("format", "f", "cid format for blocks to be created with.").WithDefault("v0"),
131
+ cmdkit.StringOption("mhtype", "multihash hash function").WithDefault("sha2-256"),
132
+ cmdkit.IntOption("mhlen", "multihash hash length").WithDefault(-1),
133
},
134
Run: func(req cmds.Request, res cmds.ResponseEmitter) {
135
n, err := req.InvocContext().GetNode()
core/commands/dag/dag.go
+3
-3
@@ -59,10 +59,10 @@ into an object of the specified format.
59
cmdkit.FileArg("object data", true, true, "The object to put").EnableStdin(),
60
},
61
Options: []cmdkit.Option{
62
- cmdkit.StringOption("format", "f", "Format that the object will be added as.").Default("cbor"),
63
- cmdkit.StringOption("input-enc", "Format that the input object will be.").Default("json"),
62
+ cmdkit.StringOption("format", "f", "Format that the object will be added as.").WithDefault("cbor"),
63
+ cmdkit.StringOption("input-enc", "Format that the input object will be.").WithDefault("json"),
64
cmdkit.BoolOption("pin", "Pin this object when adding."),
65
- cmdkit.StringOption("hash", "Hash function to use").Default(""),
65
+ cmdkit.StringOption("hash", "Hash function to use").WithDefault(""),
66
},
67
Run: func(req cmds.Request, res cmds.Response) {
68
n, err := req.InvocContext().GetNode()
core/commands/dht.go
+1
-1
@@ -140,7 +140,7 @@ var findProvidersDhtCmd = &cmds.Command{
140
},
141
Options: []cmdkit.Option{
142
cmdkit.BoolOption("verbose", "v", "Print extra information."),
143
- cmdkit.IntOption("num-providers", "n", "The number of providers to find.").Default(20),
143
+ cmdkit.IntOption("num-providers", "n", "The number of providers to find.").WithDefault(20),
144
},
145
Run: func(req cmds.Request, res cmds.Response) {
146
n, err := req.InvocContext().GetNode()
core/commands/files/files.go
+2
-2
@@ -46,7 +46,7 @@ operations.
46
`,
47
},
48
Options: []cmdkit.Option{
49
- cmdkit.BoolOption("f", "flush", "Flush target and ancestors after write.").Default(true),
49
+ cmdkit.BoolOption("f", "flush", "Flush target and ancestors after write.").WithDefault(true),
50
},
51
Subcommands: map[string]*cmds.Command{
52
"read": FilesReadCmd,
@@ -77,7 +77,7 @@ var FilesStatCmd = &cmds.Command{
77
},
78
Options: []cmdkit.Option{
79
cmdkit.StringOption("format", "Print statistics in given format. Allowed tokens: "+
80
- "<hash> <size> <cumulsize> <type> <childs>. Conflicts with other format options.").Default(
80
+ "<hash> <size> <cumulsize> <type> <childs>. Conflicts with other format options.").WithDefault(
81
`<hash>
82
Size: <size>
83
CumulativeSize: <cumulsize>
core/commands/get.go
+1
-1
@@ -46,7 +46,7 @@ may also specify the level of compression by specifying '-l=<1-9>'.
46
cmdkit.StringOption("output", "o", "The path where the output should be stored."),
47
cmdkit.BoolOption("archive", "a", "Output a TAR archive."),
48
cmdkit.BoolOption("compress", "C", "Compress the output with GZIP compression."),
49
- cmdkit.IntOption("compression-level", "l", "The level of compression (1-9).").Default(-1),
49
+ cmdkit.IntOption("compression-level", "l", "The level of compression (1-9).").WithDefault(-1),
50
},
51
PreRun: func(req cmds.Request) error {
52
_, err := getCompressOptions(req)
core/commands/ls.go
+1
-1
@@ -54,7 +54,7 @@ The JSON output contains type information.
54
},
55
Options: []cmdkit.Option{
56
cmdkit.BoolOption("headers", "v", "Print table headers (Hash, Size, Name)."),
57
- cmdkit.BoolOption("resolve-type", "Resolve linked objects to find out their types.").Default(true),
57
+ cmdkit.BoolOption("resolve-type", "Resolve linked objects to find out their types.").WithDefault(true),
58
},
59
Run: func(req cmds.Request, res cmds.Response) {
60
nd, err := req.InvocContext().GetNode()
core/commands/object/object.go
+2
-2
@@ -382,8 +382,8 @@ And then run:
382
cmdkit.FileArg("data", true, false, "Data to be stored as a DAG object.").EnableStdin(),
383
},
384
Options: []cmdkit.Option{
385
- cmdkit.StringOption("inputenc", "Encoding type of input data. One of: {\"protobuf\", \"json\"}.").Default("json"),
386
- cmdkit.StringOption("datafieldenc", "Encoding type of the data field, either \"text\" or \"base64\".").Default("text"),
385
+ cmdkit.StringOption("inputenc", "Encoding type of input data. One of: {\"protobuf\", \"json\"}.").WithDefault("json"),
386
+ cmdkit.StringOption("datafieldenc", "Encoding type of the data field, either \"text\" or \"base64\".").WithDefault("text"),
387
cmdkit.BoolOption("pin", "Pin this object when adding."),
388
},
389
Run: func(req cmds.Request, res cmds.Response) {
core/commands/pin.go
+4
-4
@@ -54,7 +54,7 @@ var addPinCmd = &cmds.Command{
54
cmdkit.StringArg("ipfs-path", true, true, "Path to object(s) to be pinned.").EnableStdin(),
55
},
56
Options: []cmdkit.Option{
57
- cmdkit.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s).").Default(true),
57
+ cmdkit.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s).").WithDefault(true),
58
cmdkit.BoolOption("progress", "Show progress"),
59
},
60
Type: AddPinOutput{},
@@ -181,7 +181,7 @@ collected if needed. (By default, recursively. Use -r=false for direct pins.)
181
cmdkit.StringArg("ipfs-path", true, true, "Path to object(s) to be unpinned.").EnableStdin(),
182
},
183
Options: []cmdkit.Option{
184
- cmdkit.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s).").Default(true),
184
+ cmdkit.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s).").WithDefault(true),
185
},
186
Type: PinOutput{},
187
Run: func(req cmds.Request, res cmds.Response) {
@@ -275,7 +275,7 @@ Example:
275
cmdkit.StringArg("ipfs-path", false, true, "Path to object(s) to be listed."),
276
},
277
Options: []cmdkit.Option{
278
- cmdkit.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").Default("all"),
278
+ cmdkit.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").WithDefault("all"),
279
cmdkit.BoolOption("quiet", "q", "Write just hashes of objects."),
280
},
281
Run: func(req cmds.Request, res cmds.Response) {
@@ -358,7 +358,7 @@ new pin and removing the old one.
358
cmdkit.StringArg("to-path", true, false, "Path to new object to be pinned."),
359
},
360
Options: []cmdkit.Option{
361
- cmdkit.BoolOption("unpin", "Remove the old pin.").Default(true),
361
+ cmdkit.BoolOption("unpin", "Remove the old pin.").WithDefault(true),
362
},
363
Type: PinOutput{},
364
Run: func(req cmds.Request, res cmds.Response) {
core/commands/ping.go
+1
-1
@@ -39,7 +39,7 @@ trip latency information.
39
cmdkit.StringArg("peer ID", true, true, "ID of peer to be pinged.").EnableStdin(),
40
},
41
Options: []cmdkit.Option{
42
- cmdkit.IntOption("count", "n", "Number of ping messages to send.").Default(10),
42
+ cmdkit.IntOption("count", "n", "Number of ping messages to send.").WithDefault(10),
43
},
44
Marshalers: cmds.MarshalerMap{
45
cmds.Text: func(res cmds.Response) (io.Reader, error) {
core/commands/publish.go
+3
-3
@@ -65,13 +65,13 @@ Alternatively, publish an <ipfs-path> using a valid PeerID (as listed by
65
cmdkit.StringArg("ipfs-path", true, false, "ipfs path of the object to be published.").EnableStdin(),
66
},
67
Options: []cmdkit.Option{
68
- cmdkit.BoolOption("resolve", "Resolve given path before publishing.").Default(true),
68
+ cmdkit.BoolOption("resolve", "Resolve given path before publishing.").WithDefault(true),
69
cmdkit.StringOption("lifetime", "t",
70
`Time duration that the record will be valid for. <<default>>
71
This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are
72
- "ns", "us" (or "µs"), "ms", "s", "m", "h".`).Default("24h"),
72
+ "ns", "us" (or "µs"), "ms", "s", "m", "h".`).WithDefault("24h"),
73
cmdkit.StringOption("ttl", "Time duration this record should be cached for (caution: experimental)."),
74
- 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"),
74
+ 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"),
75
},
76
Run: func(req cmds.Request, res cmds.Response) {
77
n, err := req.InvocContext().GetNode()
core/commands/refs.go
+1
-1
@@ -61,7 +61,7 @@ NOTE: List all references recursively by using the flag '-r'.
61
cmdkit.StringArg("ipfs-path", true, true, "Path to the object(s) to list refs from.").EnableStdin(),
62
},
63
Options: []cmdkit.Option{
64
- cmdkit.StringOption("format", "Emit edges with given format. Available tokens: <src> <dst> <linkname>.").Default("<dst>"),
64
+ cmdkit.StringOption("format", "Emit edges with given format. Available tokens: <src> <dst> <linkname>.").WithDefault("<dst>"),
65
cmdkit.BoolOption("edges", "e", "Emit edge format: `<from> -> <to>`."),
66
cmdkit.BoolOption("unique", "u", "Omit duplicate refs from output."),
67
cmdkit.BoolOption("recursive", "r", "Recursively list links of child nodes."),
core/commands/stat.go
+1
-1
@@ -76,7 +76,7 @@ Example:
76
cmdkit.StringOption("interval", "i", `Time interval to wait between updating output, if 'poll' is true.
77
78
This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are:
79
- "ns", "us" (or "µs"), "ms", "s", "m", "h".`).Default("1s"),
79
+ "ns", "us" (or "µs"), "ms", "s", "m", "h".`).WithDefault("1s"),
80
},
81
82
Run: func(req cmds.Request, res cmds.ResponseEmitter) {