Commit 8ee3e996 authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

core/commands2: Use Option constructors in commands

parent 38b31c65
......@@ -20,14 +20,10 @@ var initCmd = &cmds.Command{
`,
Options: []cmds.Option{
cmds.Option{[]string{"bits", "b"}, cmds.Int,
"Number of bits to use in the generated RSA private key (defaults to 4096)"},
cmds.Option{[]string{"passphrase", "p"}, cmds.String,
"Passphrase for encrypting the private key"},
cmds.Option{[]string{"force", "f"}, cmds.Bool,
"Overwrite existing config (if it exists)"},
cmds.Option{[]string{"datastore", "d"}, cmds.String,
"Location for the IPFS data store"},
cmds.IntOption("bits", "b", "Number of bits to use in the generated RSA private key (defaults to 4096)"),
cmds.StringOption("passphrase", "p", "Passphrase for encrypting the private key"),
cmds.BoolOption("force", "f", "Overwrite existing config (if it exists)"),
cmds.StringOption("datastore", "d", "Location for the IPFS data store"),
},
Run: func(req cmds.Request) (interface{}, error) {
......
......@@ -23,7 +23,7 @@ type AddOutput struct {
var addCmd = &cmds.Command{
Options: []cmds.Option{
cmds.Option{[]string{"recursive", "r"}, cmds.Bool, "Must be specified when adding directories"},
cmds.BoolOption("recursive", "r", "Must be specified when adding directories"),
},
Arguments: []cmds.Argument{
cmds.Argument{"file", cmds.ArgFile, true, true, "The path to a file to be added to IPFS"},
......
......@@ -24,16 +24,11 @@ not be listable, as it is virtual. Accessing known paths directly.
`,
Options: []cmds.Option{
// TODO text: specify a mountpoint for ipfs
// TODO longform
cmds.Option{[]string{"f"}, cmds.String,
"The path where IPFS should be mounted\n(default is '/ipfs')"},
cmds.StringOption("f", "The path where IPFS should be mounted\n(default is '/ipfs')"),
// TODO text: specify a mountpoint for ipns
// TODO longform
cmds.Option{[]string{"n"}, cmds.String,
"The path where IPNS should be mounted\n(default is '/ipns')"},
cmds.StringOption("n", "The path where IPNS should be mounted\n(default is '/ipns')"),
},
Run: func(req cmds.Request) (interface{}, error) {
ctx := req.Context()
......
......@@ -29,8 +29,7 @@ on disk.
"Path to object(s) to be pinned"},
},
Options: []cmds.Option{
cmds.Option{[]string{"recursive", "r"}, cmds.Bool,
"Recursively pin the object linked to by the specified object(s)"},
cmds.BoolOption("recursive", "r", "Recursively pin the object linked to by the specified object(s)"),
},
Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node
......@@ -65,8 +64,7 @@ collected if needed.
"Path to object(s) to be unpinned"},
},
Options: []cmds.Option{
cmds.Option{[]string{"recursive", "r"}, cmds.Bool,
"Recursively unpin the object linked to by the specified object(s)"},
cmds.BoolOption("recursive", "r", "Recursively unpin the object linked to by the specified object(s)"),
},
Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node
......
......@@ -29,10 +29,8 @@ Note: list all refs recursively with -r.`,
"Path to the object(s) to list refs from"},
},
Options: []cmds.Option{
cmds.Option{[]string{"unique", "u"}, cmds.Bool,
"Omit duplicate refs from output"},
cmds.Option{[]string{"recursive", "r"}, cmds.Bool,
"Recursively list links of child nodes"},
cmds.BoolOption("unique", "u", "Omit duplicate refs from output"),
cmds.BoolOption("recursive", "r", "Recursively list links of child nodes"),
},
Run: func(req cmds.Request) (interface{}, error) {
n := req.Context().Node
......
......@@ -44,14 +44,10 @@ Use "ipfs <command> --help" for more information about a command.
`,
Options: []cmds.Option{
cmds.Option{[]string{"config", "c"}, cmds.String,
"Path to the configuration file to use"},
cmds.Option{[]string{"debug", "D"}, cmds.Bool,
"Operate in debug mode"},
cmds.Option{[]string{"help", "h"}, cmds.Bool,
"Show the command help text"},
cmds.Option{[]string{"local", "L"}, cmds.Bool,
"Run the command locally, instead of using the daemon"},
cmds.StringOption("config", "c", "Path to the configuration file to use"),
cmds.BoolOption("debug", "D", "Operate in debug mode"),
cmds.BoolOption("help", "h", "Show the command help text"),
cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon"),
},
}
......
......@@ -17,8 +17,7 @@ var versionCmd = &cmds.Command{
`,
Options: []cmds.Option{
cmds.Option{[]string{"number", "n"}, cmds.Bool,
"Only output the version number"},
cmds.BoolOption("number", "n", "Only output the version number"),
},
Run: func(req cmds.Request) (interface{}, error) {
return &VersionOutput{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment