summaryrefslogtreecommitdiff
path: root/src/mongo/db/server_options.cpp
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@10gen.com>2013-10-21 13:00:20 -0400
committerShaun Verch <shaun.verch@10gen.com>2013-10-23 19:41:30 -0400
commit1c6ad3e411e431cf81da9f7d514fa20ec4fe792a (patch)
tree8f69f9a92565febf53d251c9399fdba1fe3f2e56 /src/mongo/db/server_options.cpp
parent22f5a8622731353890352dbaccdebdc937ae8508 (diff)
downloadmongo-1c6ad3e411e431cf81da9f7d514fa20ec4fe792a.tar.gz
SERVER-11144 Use new chaining interface in options
Diffstat (limited to 'src/mongo/db/server_options.cpp')
-rw-r--r--src/mongo/db/server_options.cpp308
1 files changed, 115 insertions, 193 deletions
diff --git a/src/mongo/db/server_options.cpp b/src/mongo/db/server_options.cpp
index bbd60e8d684..4c935ee2884 100644
--- a/src/mongo/db/server_options.cpp
+++ b/src/mongo/db/server_options.cpp
@@ -111,21 +111,13 @@ namespace {
maxConnInfoBuilder << "max number of simultaneous connections - "
<< DEFAULT_MAX_CONN << " by default";
- Status ret = options->addOption(OD("help", "help,h", moe::Switch,
- "show this usage information", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("version", "version", moe::Switch, "show version information",
- true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("config", "config,f", moe::String,
- "configuration file specifying additional options", true));
- if (!ret.isOK()) {
- return ret;
- }
+ options->addOptionChaining("help", "help,h", moe::Switch, "show this usage information");
+
+ options->addOptionChaining("version", "version", moe::Switch, "show version information");
+
+ options->addOptionChaining("config", "config,f", moe::String,
+ "configuration file specifying additional options");
+
// The verbosity level can be set at startup in the following ways. Note that if multiple
// methods for setting the verbosity are specified simultaneously, the verbosity will be set
// based on the whichever option specifies the highest level
@@ -155,200 +147,130 @@ namespace {
// { "verbose" : "vv" }| 2 (etc.)
// { "v" : true } | 1
// { "vv" : true } | 2 (etc.)
- ret = options->addOption(OD("verbose", "verbose,v", moe::String,
- "be more verbose (include multiple times for more verbosity e.g. -vvvvv)",
- true, moe::Value(),
- moe::Value(std::string("v"))));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("quiet", "quiet", moe::Switch, "quieter output", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("port", "port", moe::Int, portInfoBuilder.str().c_str(), true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("bind_ip", "bind_ip", moe::String,
- "comma separated list of ip addresses to listen on - all local ips by default",
- true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("maxConns", "maxConns", moe::Int,
- maxConnInfoBuilder.str().c_str(), true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("logpath", "logpath", moe::String,
- "log file to send write to instead of stdout - has to be a file, not directory",
- true));
- if (!ret.isOK()) {
- return ret;
- }
+ options->addOptionChaining("verbose", "verbose,v", moe::String,
+ "be more verbose (include multiple times for more verbosity e.g. -vvvvv)")
+ .setImplicit(moe::Value(std::string("v")));
+
+ options->addOptionChaining("quiet", "quiet", moe::Switch, "quieter output");
+
+ options->addOptionChaining("port", "port", moe::Int, portInfoBuilder.str().c_str());
+
+ options->addOptionChaining("bind_ip", "bind_ip", moe::String,
+ "comma separated list of ip addresses to listen on - all local ips by default");
+
+ options->addOptionChaining("maxConns", "maxConns", moe::Int,
+ maxConnInfoBuilder.str().c_str());
+
+ options->addOptionChaining("logpath", "logpath", moe::String,
+ "log file to send write to instead of stdout - has to be a file, not directory");
+
#ifndef _WIN32
- ret = options->addOption(OD("syslogFacility", "syslogFacility", moe::String,
- "syslog facility used for monogdb syslog message",
- true));
- if (!ret.isOK()) {
- return ret;
- }
+ options->addOptionChaining("syslogFacility", "syslogFacility", moe::String,
+ "syslog facility used for monogdb syslog message");
+
#endif // _WIN32
- ret = options->addOption(OD("logappend", "logappend", moe::Switch,
- "append to logpath instead of over-writing", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("logTimestampFormat", "logTimestampFormat", moe::String,
- "Desired format for timestamps in log messages. One of ctime, "
- "iso8601-utc or iso8601-local", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("pidfilepath", "pidfilepath", moe::String,
- "full path to pidfile (if not set, no pidfile is created)", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("keyFile", "keyFile", moe::String,
- "private key for cluster authentication", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("setParameter", "setParameter", moe::StringVector,
- "Set a configurable parameter", true, moe::Value(), moe::Value(), true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("httpinterface", "httpinterface", moe::Switch,
- "enable http interface", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("clusterAuthMode", "clusterAuthMode", moe::String,
- "Authentication mode used for cluster authentication. Alternatives are "
- "(keyfile|sendKeyfile|sendX509|x509)", true));
- if (!ret.isOK()) {
- return ret;
- }
+ options->addOptionChaining("logappend", "logappend", moe::Switch,
+ "append to logpath instead of over-writing");
+
+ options->addOptionChaining("logTimestampFormat", "logTimestampFormat", moe::String,
+ "Desired format for timestamps in log messages. One of ctime, "
+ "iso8601-utc or iso8601-local");
+
+ options->addOptionChaining("pidfilepath", "pidfilepath", moe::String,
+ "full path to pidfile (if not set, no pidfile is created)");
+
+ options->addOptionChaining("keyFile", "keyFile", moe::String,
+ "private key for cluster authentication");
+
+ options->addOptionChaining("setParameter", "setParameter", moe::StringVector,
+ "Set a configurable parameter")
+ .composing();
+
+ options->addOptionChaining("httpinterface", "httpinterface", moe::Switch,
+ "enable http interface");
+
+ options->addOptionChaining("clusterAuthMode", "clusterAuthMode", moe::String,
+ "Authentication mode used for cluster authentication. Alternatives are "
+ "(keyfile|sendKeyfile|sendX509|x509)");
+
#ifndef _WIN32
- ret = options->addOption(OD("nounixsocket", "nounixsocket", moe::Switch,
- "disable listening on unix sockets", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("unixSocketPrefix", "unixSocketPrefix", moe::String,
- "alternative directory for UNIX domain sockets (defaults to /tmp)", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("fork", "fork", moe::Switch, "fork server process", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("syslog", "syslog", moe::Switch,
- "log to system's syslog facility instead of file or stdout", true));
- if (!ret.isOK()) {
- return ret;
- }
+ options->addOptionChaining("nounixsocket", "nounixsocket", moe::Switch,
+ "disable listening on unix sockets");
+
+ options->addOptionChaining("unixSocketPrefix", "unixSocketPrefix", moe::String,
+ "alternative directory for UNIX domain sockets (defaults to /tmp)");
+
+ options->addOptionChaining("fork", "fork", moe::Switch, "fork server process");
+
+ options->addOptionChaining("syslog", "syslog", moe::Switch,
+ "log to system's syslog facility instead of file or stdout");
+
#endif
/* support for -vv -vvvv etc. */
for (string s = "vv"; s.length() <= 12; s.append("v")) {
- ret = options->addOption(OD(s.c_str(), s.c_str(), moe::Switch, "verbose", false));
- if(!ret.isOK()) {
- return ret;
- }
+ options->addOptionChaining(s.c_str(), s.c_str(), moe::Switch, "verbose")
+ .hidden();
}
// Extra hidden options
- ret = options->addOption(OD("nohttpinterface", "nohttpinterface", moe::Switch,
- "disable http interface", false));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("objcheck", "objcheck", moe::Switch,
- "inspect client data for validity on receipt (DEFAULT)", false));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("noobjcheck", "noobjcheck", moe::Switch,
- "do NOT inspect client data for validity on receipt", false));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("traceExceptions", "traceExceptions", moe::Switch,
- "log stack traces for every exception", false));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("enableExperimentalIndexStatsCmd",
- "enableExperimentalIndexStatsCmd", moe::Switch,
- "EXPERIMENTAL (UNSUPPORTED). "
- "Enable command computing aggregate statistics on indexes.", false));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("enableExperimentalStorageDetailsCmd",
- "enableExperimentalStorageDetailsCmd", moe::Switch,
- "EXPERIMENTAL (UNSUPPORTED). "
- "Enable command computing aggregate statistics on storage.", false));
- if (!ret.isOK()) {
- return ret;
- }
+ options->addOptionChaining("nohttpinterface", "nohttpinterface", moe::Switch,
+ "disable http interface")
+ .hidden();
+
+ options->addOptionChaining("objcheck", "objcheck", moe::Switch,
+ "inspect client data for validity on receipt (DEFAULT)")
+ .hidden();
+
+ options->addOptionChaining("noobjcheck", "noobjcheck", moe::Switch,
+ "do NOT inspect client data for validity on receipt")
+ .hidden();
+
+ options->addOptionChaining("traceExceptions", "traceExceptions", moe::Switch,
+ "log stack traces for every exception")
+ .hidden();
+
+ options->addOptionChaining("enableExperimentalIndexStatsCmd",
+ "enableExperimentalIndexStatsCmd", moe::Switch, "EXPERIMENTAL (UNSUPPORTED). "
+ "Enable command computing aggregate statistics on indexes.")
+ .hidden();
+
+ options->addOptionChaining("enableExperimentalStorageDetailsCmd",
+ "enableExperimentalStorageDetailsCmd", moe::Switch, "EXPERIMENTAL (UNSUPPORTED). "
+ "Enable command computing aggregate statistics on storage.")
+ .hidden();
+
return Status::OK();
}
Status addWindowsServerOptions(moe::OptionSection* options) {
- Status ret = options->addOption(OD("install", "install", moe::Switch,
- "install Windows service", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("remove", "remove", moe::Switch, "remove Windows service",
- true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("reinstall", "reinstall", moe::Switch,
- "reinstall Windows service (equivalent to --remove followed by --install)",
- true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("serviceName", "serviceName", moe::String,
- "Windows service name", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("serviceDisplayName", "serviceDisplayName", moe::String,
- "Windows service display name", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("serviceDescription", "serviceDescription", moe::String,
- "Windows service description", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("serviceUser", "serviceUser", moe::String,
- "account for service execution", true));
- if (!ret.isOK()) {
- return ret;
- }
- ret = options->addOption(OD("servicePassword", "servicePassword", moe::String,
- "password used to authenticate serviceUser", true));
- if (!ret.isOK()) {
- return ret;
- }
+ options->addOptionChaining("install", "install", moe::Switch, "install Windows service");
+
+ options->addOptionChaining("remove", "remove", moe::Switch, "remove Windows service");
+
+ options->addOptionChaining("reinstall", "reinstall", moe::Switch,
+ "reinstall Windows service (equivalent to --remove followed by --install)");
+
+ options->addOptionChaining("serviceName", "serviceName", moe::String,
+ "Windows service name");
+
+ options->addOptionChaining("serviceDisplayName", "serviceDisplayName", moe::String,
+ "Windows service display name");
+
+ options->addOptionChaining("serviceDescription", "serviceDescription", moe::String,
+ "Windows service description");
+
+ options->addOptionChaining("serviceUser", "serviceUser", moe::String,
+ "account for service execution");
+
+ options->addOptionChaining("servicePassword", "servicePassword", moe::String,
+ "password used to authenticate serviceUser");
+
+
+ options->addOptionChaining("service", "service", moe::Switch, "start mongodb service")
+ .hidden();
- ret = options->addOption(OD("service", "service", moe::Switch, "start mongodb service",
- false));
- if (!ret.isOK()) {
- return ret;
- }
return Status::OK();
}