Skip to content

Commit

Permalink
cmds: rename DefaultVal -> Default, Default -> WithDefault
Browse files Browse the repository at this point in the history
Propagate change from cmdkit.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
  • Loading branch information
Stebalien committed Nov 21, 2017
1 parent 76e1da0 commit bcd2541
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,19 @@ 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."),
cmdkit.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount). Defaults to config setting."),
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)"),
Expand Down
2 changes: 1 addition & 1 deletion cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ','"),

Expand Down
2 changes: 1 addition & 1 deletion commands/cli/helptext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion commands/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions core/commands/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
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()
Expand Down
6 changes: 3 additions & 3 deletions core/commands/dag/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -77,7 +77,7 @@ var FilesStatCmd = &cmds.Command{
},
Options: []cmdkit.Option{
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>
Size: <size>
CumulativeSize: <cumulsize>
Expand Down
2 changes: 1 addition & 1 deletion core/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion core/commands/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions core/commands/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
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. <<default>>
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>>.").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) {
n, err := req.InvocContext().GetNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: <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("unique", "u", "Omit duplicate refs from output."),
cmdkit.BoolOption("recursive", "r", "Recursively list links of child nodes."),
Expand Down
2 changes: 1 addition & 1 deletion core/commands/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bcd2541

Please sign in to comment.