Skip to content

Commit

Permalink
remove all instances of Default(false)
Browse files Browse the repository at this point in the history
Boolean options always default to false.

License: MIT
Signed-off-by: Lorenzo Manacorda <[email protected]>
  • Loading branch information
asymmetric committed Jul 6, 2017
1 parent 0b481a3 commit a3ebfa2
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 49 deletions.
14 changes: 7 additions & 7 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ Headers.
},

Options: []cmds.Option{
cmds.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized").Default(false),
cmds.BoolOption(initOptionKwd, "Initialize ipfs with default settings if not already initialized"),
cmds.StringOption(routingOptionKwd, "Overrides the routing option").Default("dht"),
cmds.BoolOption(mountKwd, "Mounts IPFS to the filesystem").Default(false),
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)").Default(false),
cmds.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."),
cmds.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount). Defaults to config setting."),
cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes").Default(false),
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)").Default(false),
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection").Default(false),
cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
cmds.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").Default(true),
cmds.BoolOption(offlineKwd, "Run offline. Do not connect to the rest of the network but provide local API.").Default(false),
cmds.BoolOption(offlineKwd, "Run offline. Do not connect to the rest of the network but provide local API."),
cmds.BoolOption(migrateKwd, "If true, assume yes at the migrate prompt. If false, assume no."),
cmds.BoolOption(enableFloodSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
cmds.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").Default(true),
Expand Down
3 changes: 2 additions & 1 deletion cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

context "context"

assets "github.com/ipfs/go-ipfs/assets"
cmds "github.com/ipfs/go-ipfs/commands"
core "github.com/ipfs/go-ipfs/core"
Expand Down Expand Up @@ -47,7 +48,7 @@ environment variable:
},
Options: []cmds.Option{
cmds.IntOption("bits", "b", "Number of bits to use in the generated RSA private key.").Default(nBitsForKeypairDefault),
cmds.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage.").Default(false),
cmds.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage."),
cmds.StringOption("profile", "p", "Apply profile settings to config. Multiple profiles can be separated by ','"),

// TODO need to decide whether to expose the override as a file or a
Expand Down
2 changes: 1 addition & 1 deletion commands/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const (

// options that are used by this package
var OptionEncodingType = StringOption(EncLong, EncShort, "The encoding type the output should be encoded with (json, xml, or text)")
var OptionRecursivePath = BoolOption(RecLong, RecShort, "Add directory paths recursively").Default(false)
var OptionRecursivePath = BoolOption(RecLong, RecShort, "Add directory paths recursively")
var OptionStreamChannels = BoolOption(ChanOpt, "Stream channel output")
var OptionTimeout = StringOption(TimeoutOpt, "set a global timeout on the command")

Expand Down
2 changes: 1 addition & 1 deletion core/commands/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Lists running and recently run commands.
res.SetOutput(req.InvocContext().ReqLog.Report())
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
cmds.BoolOption("verbose", "v", "Print extra information."),
},
Subcommands: map[string]*cmds.Command{
"clear": clearInactiveCmd,
Expand Down
4 changes: 2 additions & 2 deletions core/commands/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ It takes a list of base58 encoded multihashs to remove.
cmds.StringArg("hash", true, true, "Bash58 encoded multihash of block(s) to remove."),
},
Options: []cmds.Option{
cmds.BoolOption("force", "f", "Ignore nonexistent blocks.").Default(false),
cmds.BoolOption("quiet", "q", "Write minimal output.").Default(false),
cmds.BoolOption("force", "f", "Ignore nonexistent blocks."),
cmds.BoolOption("quiet", "q", "Write minimal output."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func CommandsCmd(root *cmds.Command) *cmds.Command {
ShortDescription: `Lists all available commands (and subcommands) and exits.`,
},
Options: []cmds.Option{
cmds.BoolOption(flagsOptionName, "f", "Show command flags").Default(false),
cmds.BoolOption(flagsOptionName, "f", "Show command flags"),
},
Run: func(req cmds.Request, res cmds.Response) {
rootCmd := cmd2outputCmd("ipfs", root)
Expand Down
4 changes: 2 additions & 2 deletions core/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Set the value of the 'Datastore.Path' key:
cmds.StringArg("value", false, false, "The value to set the config entry to."),
},
Options: []cmds.Option{
cmds.BoolOption("bool", "Set a boolean value.").Default(false),
cmds.BoolOption("json", "Parse stringified JSON.").Default(false),
cmds.BoolOption("bool", "Set a boolean value."),
cmds.BoolOption("json", "Parse stringified JSON."),
},
Run: func(req cmds.Request, res cmds.Response) {
args := req.Arguments()
Expand Down
14 changes: 7 additions & 7 deletions core/commands/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var queryDhtCmd = &cmds.Command{
cmds.StringArg("peerID", true, true, "The peerID to run the query against."),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
cmds.BoolOption("verbose", "v", "Print extra information."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -144,7 +144,7 @@ var findProvidersDhtCmd = &cmds.Command{
cmds.StringArg("key", true, true, "The key to find providers for."),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
cmds.BoolOption("verbose", "v", "Print extra information."),
cmds.IntOption("num-providers", "n", "The number of providers to find.").Default(20),
},
Run: func(req cmds.Request, res cmds.Response) {
Expand Down Expand Up @@ -259,8 +259,8 @@ var provideRefDhtCmd = &cmds.Command{
cmds.StringArg("key", true, true, "The key[s] to send provide records for.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
cmds.BoolOption("recursive", "r", "Recursively provide entire graph.").Default(false),
cmds.BoolOption("verbose", "v", "Print extra information."),
cmds.BoolOption("recursive", "r", "Recursively provide entire graph."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -410,7 +410,7 @@ var findPeerDhtCmd = &cmds.Command{
cmds.StringArg("peerID", true, true, "The ID of the peer to search for."),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
cmds.BoolOption("verbose", "v", "Print extra information."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -517,7 +517,7 @@ Different key types can specify other 'best' rules.
cmds.StringArg("key", true, true, "The key to find a value for."),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
cmds.BoolOption("verbose", "v", "Print extra information."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -635,7 +635,7 @@ NOTE: A value may not exceed 2048 bytes.
cmds.StringArg("value", true, false, "The value to store.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Print extra information.").Default(false),
cmds.BoolOption("verbose", "v", "Print extra information."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The resolver can recursively resolve:
cmds.StringArg("domain-name", true, false, "The domain-name name to resolve.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("recursive", "r", "Resolve until the result is not a DNS link.").Default(false),
cmds.BoolOption("recursive", "r", "Resolve until the result is not a DNS link."),
},
Run: func(req cmds.Request, res cmds.Response) {

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 @@ -75,8 +75,8 @@ Size: <size>
CumulativeSize: <cumulsize>
ChildBlocks: <childs>
Type: <type>`),
cmds.BoolOption("hash", "Print only hash. Implies '--format=<hash>'. Conflicts with other format options.").Default(false),
cmds.BoolOption("size", "Print only size. Implies '--format=<cumulsize>'. Conflicts with other format options.").Default(false),
cmds.BoolOption("hash", "Print only hash. Implies '--format=<hash>'. Conflicts with other format options."),
cmds.BoolOption("size", "Print only size. Implies '--format=<cumulsize>'. Conflicts with other format options."),
},
Run: func(req cmds.Request, res cmds.Response) {

Expand Down
4 changes: 2 additions & 2 deletions core/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ may also specify the level of compression by specifying '-l=<1-9>'.
},
Options: []cmds.Option{
cmds.StringOption("output", "o", "The path where the output should be stored."),
cmds.BoolOption("archive", "a", "Output a TAR archive.").Default(false),
cmds.BoolOption("compress", "C", "Compress the output with GZIP compression.").Default(false),
cmds.BoolOption("archive", "a", "Output a TAR archive."),
cmds.BoolOption("compress", "C", "Compress the output with GZIP compression."),
cmds.IntOption("compression-level", "l", "The level of compression (1-9).").Default(-1),
},
PreRun: func(req cmds.Request) error {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/ipns.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Resolve the value of a dnslink:
cmds.StringArg("name", false, false, "The IPNS name to resolve. Defaults to your node's peerID."),
},
Options: []cmds.Option{
cmds.BoolOption("recursive", "r", "Resolve until the result is not an IPNS name.").Default(false),
cmds.BoolOption("recursive", "r", "Resolve until the result is not an IPNS name."),
cmds.BoolOption("nocache", "n", "Do not use cached entries.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The JSON output contains type information.
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name).").Default(false),
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name)."),
cmds.BoolOption("resolve-type", "Resolve linked objects to find out their types.").Default(true),
},
Run: func(req cmds.Request, res cmds.Response) {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ multihash.
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name).").Default(false),
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name)."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/object/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ to a file containing 'bar', and returns the hash of the new object.
cmds.StringArg("ref", true, false, "IPFS object to add link to."),
},
Options: []cmds.Option{
cmds.BoolOption("create", "p", "Create intermediary nodes.").Default(false),
cmds.BoolOption("create", "p", "Create intermediary nodes."),
},
Run: func(req cmds.Request, res cmds.Response) {
nd, err := req.InvocContext().GetNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Example:
},
Options: []cmds.Option{
cmds.StringOption("type", "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").Default("all"),
cmds.BoolOption("quiet", "q", "Write just hashes of objects.").Default(false),
cmds.BoolOption("quiet", "q", "Write just hashes of objects."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down
6 changes: 3 additions & 3 deletions core/commands/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ NOTE: List all references recursively by using the flag '-r'.
},
Options: []cmds.Option{
cmds.StringOption("format", "Emit edges with given format. Available tokens: <src> <dst> <linkname>.").Default("<dst>"),
cmds.BoolOption("edges", "e", "Emit edge format: `<from> -> <to>`.").Default(false),
cmds.BoolOption("unique", "u", "Omit duplicate refs from output.").Default(false),
cmds.BoolOption("recursive", "r", "Recursively list links of child nodes.").Default(false),
cmds.BoolOption("edges", "e", "Emit edge format: `<from> -> <to>`."),
cmds.BoolOption("unique", "u", "Omit duplicate refs from output."),
cmds.BoolOption("recursive", "r", "Recursively list links of child nodes."),
},
Run: func(req cmds.Request, res cmds.Response) {
ctx := req.Context()
Expand Down
6 changes: 3 additions & 3 deletions core/commands/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ order to reclaim hard disk space.
`,
},
Options: []cmds.Option{
cmds.BoolOption("quiet", "q", "Write minimal output.").Default(false),
cmds.BoolOption("stream-errors", "Stream errors.").Default(false),
cmds.BoolOption("quiet", "q", "Write minimal output."),
cmds.BoolOption("stream-errors", "Stream errors."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -167,7 +167,7 @@ Version string The repo version.
res.SetOutput(stat)
},
Options: []cmds.Option{
cmds.BoolOption("human", "Output RepoSize in MiB.").Default(false),
cmds.BoolOption("human", "Output RepoSize in MiB."),
},
Type: corerepo.Stat{},
Marshalers: cmds.MarshalerMap{
Expand Down
2 changes: 1 addition & 1 deletion core/commands/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Resolve the value of an IPFS DAG path:
cmds.StringArg("name", true, false, "The name to resolve.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("recursive", "r", "Resolve until the result is an IPFS name.").Default(false),
cmds.BoolOption("recursive", "r", "Resolve until the result is an IPFS name."),
},
Run: func(req cmds.Request, res cmds.Response) {

Expand Down
8 changes: 4 additions & 4 deletions core/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ The CLI will exit with one of the following values:
},
Options: []cmds.Option{
cmds.StringOption("config", "c", "Path to the configuration file to use."),
cmds.BoolOption("debug", "D", "Operate in debug mode.").Default(false),
cmds.BoolOption("help", "Show the full command help text.").Default(false),
cmds.BoolOption("h", "Show a short version of the command help text.").Default(false),
cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon.").Default(false),
cmds.BoolOption("debug", "D", "Operate in debug mode."),
cmds.BoolOption("help", "Show the full command help text."),
cmds.BoolOption("h", "Show a short version of the command help text."),
cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon."),
cmds.StringOption(ApiOption, "Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001)"),
},
}
Expand Down
2 changes: 1 addition & 1 deletion core/commands/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Example:
Options: []cmds.Option{
cmds.StringOption("peer", "p", "Specify a peer to print bandwidth for."),
cmds.StringOption("proto", "t", "Specify a protocol to print bandwidth for."),
cmds.BoolOption("poll", "Print bandwidth at an interval.").Default(false),
cmds.BoolOption("poll", "Print bandwidth at an interval."),
cmds.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:
Expand Down
2 changes: 1 addition & 1 deletion core/commands/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ var swarmAddrsLocalCmd = &cmds.Command{
`,
},
Options: []cmds.Option{
cmds.BoolOption("id", "Show peer ID in addresses.").Default(false),
cmds.BoolOption("id", "Show peer ID in addresses."),
},
Run: func(req cmds.Request, res cmds.Response) {

Expand Down
8 changes: 4 additions & 4 deletions core/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ var VersionCmd = &cmds.Command{
},

Options: []cmds.Option{
cmds.BoolOption("number", "n", "Only show the version number.").Default(false),
cmds.BoolOption("commit", "Show the commit hash.").Default(false),
cmds.BoolOption("repo", "Show repo version.").Default(false),
cmds.BoolOption("all", "Show all version information").Default(false),
cmds.BoolOption("number", "n", "Only show the version number."),
cmds.BoolOption("commit", "Show the commit hash."),
cmds.BoolOption("repo", "Show repo version."),
cmds.BoolOption("all", "Show all version information"),
},
Run: func(req cmds.Request, res cmds.Response) {
res.SetOutput(&VersionOutput{
Expand Down

0 comments on commit a3ebfa2

Please sign in to comment.