diff options
author | Shaun Verch <shaun.verch@10gen.com> | 2013-10-21 16:03:06 -0400 |
---|---|---|
committer | Shaun Verch <shaun.verch@10gen.com> | 2013-10-23 19:41:30 -0400 |
commit | 0f9712f7a666699b83cee27fa7136ea92aa9e555 (patch) | |
tree | 1fb2cb7bae43821b626eb811b3634a8703f8f77a | |
parent | 1c6ad3e411e431cf81da9f7d514fa20ec4fe792a (diff) | |
download | mongo-0f9712f7a666699b83cee27fa7136ea92aa9e555.tar.gz |
SERVER-11144 Remove old registration interface
-rw-r--r-- | src/mongo/util/options_parser/option_description.cpp | 132 | ||||
-rw-r--r-- | src/mongo/util/options_parser/option_description.h | 41 | ||||
-rw-r--r-- | src/mongo/util/options_parser/option_section.cpp | 139 | ||||
-rw-r--r-- | src/mongo/util/options_parser/option_section.h | 20 | ||||
-rw-r--r-- | src/mongo/util/options_parser/options_parser.h | 4 | ||||
-rw-r--r-- | src/mongo/util/options_parser/options_parser_test.cpp | 403 | ||||
-rw-r--r-- | src/mongo/util/options_parser/startup_options.h | 5 |
7 files changed, 405 insertions, 339 deletions
diff --git a/src/mongo/util/options_parser/option_description.cpp b/src/mongo/util/options_parser/option_description.cpp index fe052c9f716..6129d68597d 100644 --- a/src/mongo/util/options_parser/option_description.cpp +++ b/src/mongo/util/options_parser/option_description.cpp @@ -15,22 +15,154 @@ #include "mongo/util/options_parser/option_description.h" +#include "mongo/util/assert_util.h" + namespace mongo { namespace optionenvironment { + namespace { + /** + * Utility function check that the type of our Value matches our OptionType + */ + Status checkValueType(OptionType type, Value value) { + switch (type) { + case StringVector: + { + std::vector<std::string> valueType; + return value.get(&valueType); + } + case Bool: + { + bool valueType; + return value.get(&valueType); + } + case Double: + { + double valueType; + return value.get(&valueType); + } + case Int: + { + int valueType; + return value.get(&valueType); + } + case Long: + { + long valueType; + return value.get(&valueType); + } + case String: + { + std::string valueType; + return value.get(&valueType); + } + case UnsignedLongLong: + { + unsigned long long valueType; + return value.get(&valueType); + } + case Unsigned: + { + unsigned valueType; + return value.get(&valueType); + } + case Switch: + { + bool valueType; + return value.get(&valueType); + } + default: + { + StringBuilder sb; + sb << "Unrecognized option type: " << type; + return Status(ErrorCodes::InternalError, sb.str()); + } + } + } + } // namespace + OptionDescription& OptionDescription::hidden() { _isVisible = false; return *this; } + OptionDescription& OptionDescription::setDefault(Value defaultValue) { + + // Disallow registering a default for a composing option since the interaction between the + // two is unclear (for example, should we override or compose the default) + if (_isComposing) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "Cannot register a default value for a composing option"; + throw DBException(sb.str(), ErrorCodes::InternalError); + } + + // Make sure the type of our default value matches our declared type + Status ret = checkValueType(_type, defaultValue); + if (!ret.isOK()) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "mismatch between declared type and type of default value: " + << ret.toString(); + throw DBException(sb.str(), ErrorCodes::InternalError); + } + _default = defaultValue; return *this; } + OptionDescription& OptionDescription::setImplicit(Value implicitValue) { + + // Disallow registering an implicit value for a composing option since the interaction + // between the two is unclear + if (_isComposing) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "Cannot register an implicit value for a composing option"; + throw DBException(sb.str(), ErrorCodes::InternalError); + } + + // Make sure the type of our implicit value matches our declared type + Status ret = checkValueType(_type, implicitValue); + if (!ret.isOK()) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "mismatch between declared type and type of implicit value: " + << ret.toString(); + throw DBException(sb.str(), ErrorCodes::InternalError); + } + _implicit = implicitValue; return *this; } + OptionDescription& OptionDescription::composing() { + + if (_type != StringVector) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "only options registered as StringVector can be composing"; + throw DBException(sb.str(), ErrorCodes::InternalError); + } + + // Disallow registering a default value for a composing option since the interaction + // between the two is unclear + if (!_default.isEmpty()) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "Cannot make an option with an default value composing"; + throw DBException(sb.str(), ErrorCodes::InternalError); + } + + // Disallow registering an implicit value for a composing option since the interaction + // between the two is unclear + if (!_implicit.isEmpty()) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "Cannot make an option with an implicit value composing"; + throw DBException(sb.str(), ErrorCodes::InternalError); + } + _isComposing = true; return *this; } diff --git a/src/mongo/util/options_parser/option_description.h b/src/mongo/util/options_parser/option_description.h index 22fe12c0d74..56fadd93338 100644 --- a/src/mongo/util/options_parser/option_description.h +++ b/src/mongo/util/options_parser/option_description.h @@ -48,28 +48,51 @@ namespace optionenvironment { OptionDescription(const std::string& dottedName, const std::string& singleName, const OptionType type, - const std::string& description, - const bool isVisible = true, - const Value defaultValue = Value(), - const Value implicitValue = Value(), - const bool isComposing = false) + const std::string& description) : _dottedName(dottedName), _singleName(singleName), _type(type), _description(description), - _isVisible(isVisible), - _default(defaultValue), - _implicit(implicitValue), - _isComposing(isComposing) { } + _isVisible(true), + _default(Value()), + _implicit(Value()), + _isComposing(false) { } /* * The following functions are part of the chaining interface for option registration. See * comments below for what each of these attributes mean, and the OptionSection class for * more details on the chaining interface. */ + + /* + * Make this option hidden so it does not appear in command line help + */ OptionDescription& hidden(); + + /* + * Add a default value for this option if it is not specified + * + * throws DBException on errors, such as trying to set a default that does not have the same + * type as the option, or trying to set a default for a composing option. + */ OptionDescription& setDefault(Value defaultValue); + + /* + * Add an implicit value for this option if it is specified with no argument + * + * throws DBException on errors, such as trying to set an implicit value that does not have + * the same type as the option, or trying to set an implicit value for a composing option. + */ OptionDescription& setImplicit(Value implicitValue); + + /* + * Make this option composing so that the different sources add their values instead of + * overriding (eg. setParameter values in the config file and on the command line all get + * aggregated together) + * + * throws DBException on errors, such as trying to make an option that is not a vector type + * composing, or or trying to set an implicit or default value for a composing option. + */ OptionDescription& composing(); std::string _dottedName; // Used for JSON config and in Environment diff --git a/src/mongo/util/options_parser/option_section.cpp b/src/mongo/util/options_parser/option_section.cpp index 1fef8c21b54..bfd41d507b3 100644 --- a/src/mongo/util/options_parser/option_section.cpp +++ b/src/mongo/util/options_parser/option_section.cpp @@ -26,67 +26,6 @@ namespace optionenvironment { // Registration interface - namespace { - /** - * Utility function check that the type of our Value matches our OptionType - */ - Status checkValueType(OptionType type, Value value) { - switch (type) { - case StringVector: - { - std::vector<std::string> valueType; - return value.get(&valueType); - } - case Bool: - { - bool valueType; - return value.get(&valueType); - } - case Double: - { - double valueType; - return value.get(&valueType); - } - case Int: - { - int valueType; - return value.get(&valueType); - } - case Long: - { - long valueType; - return value.get(&valueType); - } - case String: - { - std::string valueType; - return value.get(&valueType); - } - case UnsignedLongLong: - { - unsigned long long valueType; - return value.get(&valueType); - } - case Unsigned: - { - unsigned valueType; - return value.get(&valueType); - } - case Switch: - { - bool valueType; - return value.get(&valueType); - } - default: - { - StringBuilder sb; - sb << "Unrecognized option type: " << type; - return Status(ErrorCodes::InternalError, sb.str()); - } - } - } - } // namespace - // TODO: Make sure the section we are adding does not have duplicate options Status OptionSection::addSection(const OptionSection& subSection) { if (!subSection._positionalOptions.empty()) { @@ -97,7 +36,12 @@ namespace optionenvironment { return Status::OK(); } - Status OptionSection::addOption(const OptionDescription& option) { + OptionDescription& OptionSection::addOptionChaining(const std::string& dottedName, + const std::string& singleName, + const OptionType type, + const std::string& description) { + OptionDescription option(dottedName, singleName, type, description); + // Verify that neither the single name nor the dotted name for this option conflicts with // the names for any options we have already registered std::list<OptionDescription>::const_iterator oditerator; @@ -106,70 +50,18 @@ namespace optionenvironment { StringBuilder sb; sb << "Attempted to register option with duplicate dottedName: " << option._dottedName; - return Status(ErrorCodes::InternalError, sb.str()); + throw DBException(sb.str(), ErrorCodes::InternalError); } if (option._singleName == oditerator->_singleName) { StringBuilder sb; sb << "Attempted to register option with duplicate singleName: " << option._singleName; - return Status(ErrorCodes::InternalError, sb.str()); + throw DBException(sb.str(), ErrorCodes::InternalError); } } - // Make sure the type of our default value matches our declared type - if (!option._default.isEmpty()) { - Status ret = checkValueType(option._type, option._default); - if (!ret.isOK()) { - StringBuilder sb; - sb << "Could not register option \"" << option._dottedName << "\": " - << "mismatch between declared type and type of default value: " - << ret.toString(); - return Status(ErrorCodes::TypeMismatch, sb.str()); - } - } - - // Make sure that if we are registering a composing option it has the type of StringVector - if (option._isComposing) { - if (option._type != StringVector) { - StringBuilder sb; - sb << "Could not register option \"" << option._dottedName << "\": " - << "only options registered as StringVector can be composing"; - return Status(ErrorCodes::TypeMismatch, sb.str()); - } - } - - // Disallow registering a default for a composing option since the interaction between the - // two is unclear (for example, should we override or compose the default) - if (option._isComposing && !option._default.isEmpty()) { - StringBuilder sb; - sb << "Could not register option \"" << option._dottedName << "\": " - << "Cannot register a default value for a composing option"; - return Status(ErrorCodes::InternalError, sb.str()); - } - - // Disallow registering an implicit value for a composing option since the interaction - // between the two is unclear - if (option._isComposing && !option._implicit.isEmpty()) { - StringBuilder sb; - sb << "Could not register option \"" << option._dottedName << "\": " - << "Cannot register an implicit value for a composing option"; - return Status(ErrorCodes::InternalError, sb.str()); - } - _options.push_back(option); - return Status::OK(); - } - OptionDescription& OptionSection::addOptionChaining(const std::string& dottedName, - const std::string& singleName, - const OptionType type, - const std::string& description) { - OptionDescription option(dottedName, singleName, type, description); - Status ret = addOption(option); - if (!ret.isOK()) { - // TODO: Determine if this is the exception we want to throw - throw DBException(ret.reason(), ret.code()); - } return _options.back(); } @@ -204,15 +96,16 @@ namespace optionenvironment { } } - Status ret = addOption(OptionDescription(positionalOption._name, - positionalOption._name, - positionalOption._type, - "hidden description", - false/*hidden*/)); - if (!ret.isOK()) { - return ret; + try { + addOptionChaining(positionalOption._name, positionalOption._name, + positionalOption._type, "hidden description").hidden(); + } + catch (DBException &e) { + return e.toStatus(); } + _positionalOptions.push_back(positionalOption); + return Status::OK(); } diff --git a/src/mongo/util/options_parser/option_section.h b/src/mongo/util/options_parser/option_section.h index f729bc74b1b..05d3a807c0f 100644 --- a/src/mongo/util/options_parser/option_section.h +++ b/src/mongo/util/options_parser/option_section.h @@ -45,13 +45,13 @@ namespace optionenvironment { * moe::OptionSection subSection("Section Name"); * * // Register our allowed option flags with our OptionSection - * options.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display Help")); + * options.addOptionChaining("help", "help", moe::Switch, "Display Help"); * * // Register our positional options with our OptionSection * options.addPositionalOption(moe::PositionalOptionDescription("command", moe::String)); * * // Add a subsection - * subSection.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + * subSection.addOptionChaining("port", "port", moe::Int, "Port"); * options.addSection(subSection); * * // Run the parser @@ -74,12 +74,9 @@ namespace optionenvironment { * we need generate the help string for the command line */ Status addSection(const OptionSection& subSection); + /** - * Add an option to this section - */ - Status addOption(const OptionDescription& option); - /** - * Add an option to this section, but returns a reference to an OptionDescription to allow + * Add an option to this section, and returns a reference to an OptionDescription to allow * for chaining. * * Example: @@ -92,10 +89,8 @@ namespace optionenvironment { * the OptionDescription class for details on these attributes. * * throws DBException on errors, such as attempting to register an option with the same name - * as another option, registering a composing option that does not have the type - * StringVector, or registering an option with a default value that does not match its type. - * All of these cases represent programming errors and should not happen during normal - * operation. + * as another option. These represent programming errors that should not happen during + * normal operation. */ OptionDescription& addOptionChaining(const std::string& dottedName, const std::string& singleName, @@ -106,6 +101,9 @@ namespace optionenvironment { * name as the PositionalOptionDescription because that is the mechanism boost program * options uses. Unfortunately this means that positional options can also be accessed by * name in the config files and via command line flags + * + * returns bad status on errors, such as attempting to register an option with the same name + * as another option */ Status addPositionalOption(const PositionalOptionDescription& positionalOption); diff --git a/src/mongo/util/options_parser/options_parser.h b/src/mongo/util/options_parser/options_parser.h index a336dc328f6..d7e0b44235b 100644 --- a/src/mongo/util/options_parser/options_parser.h +++ b/src/mongo/util/options_parser/options_parser.h @@ -41,8 +41,8 @@ namespace optionenvironment { * moe::OptionSection options; * * // Register our allowed options with our OptionSection - * options.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display Help")); - * options.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + * options.addOptionChaining("help", "help", moe::Switch, "Display Help"); + * options.addOptionChaining("port", "port", moe::Int, "Port"); * * // Run the parser * Status ret = parser.run(options, argv, env, &environment); diff --git a/src/mongo/util/options_parser/options_parser_test.cpp b/src/mongo/util/options_parser/options_parser_test.cpp index e8a028485c8..5171a33669e 100644 --- a/src/mongo/util/options_parser/options_parser_test.cpp +++ b/src/mongo/util/options_parser/options_parser_test.cpp @@ -55,14 +55,24 @@ namespace { TEST(Registration, DuplicateSingleName) { moe::OptionSection testOpts; - ASSERT_OK(testOpts.addOption(moe::OptionDescription("dup", "dup", moe::Switch, "dup"))); - ASSERT_NOT_OK(testOpts.addOption(moe::OptionDescription("new", "dup", moe::Switch, "dup"))); + try { + testOpts.addOptionChaining("dup", "dup", moe::Switch, "dup"); + testOpts.addOptionChaining("new", "dup", moe::Switch, "dup"); + FAIL("Was able to register duplicate single name"); + } + catch (::mongo::DBException &e) { + } } TEST(Registration, DuplicateDottedName) { moe::OptionSection testOpts; - ASSERT_OK(testOpts.addOption(moe::OptionDescription("dup", "dup", moe::Switch, "dup"))); - ASSERT_NOT_OK(testOpts.addOption(moe::OptionDescription("dup", "new", moe::Switch, "dup"))); + try { + testOpts.addOptionChaining("dup", "dup", moe::Switch, "dup"); + testOpts.addOptionChaining("dup", "new", moe::Switch, "dup"); + FAIL("Was able to register duplicate single name"); + } + catch (::mongo::DBException &e) { + } } TEST(Registration, DuplicatePositional) { @@ -74,26 +84,90 @@ namespace { } TEST(Registration, DefaultValueWrongType) { - moe::OptionsParser parser; - moe::Environment environment; + moe::OptionSection testOpts; + try { + testOpts.addOptionChaining("port", "port", moe::Int, "Port") + .setDefault(moe::Value("String")); + FAIL("Was able to register default value with wrong type"); + } + catch (::mongo::DBException &e) { + } + } + TEST(Registration, ImplicitValueWrongType) { moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - ASSERT_NOT_OK(testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port", - true, moe::Value("String")))); + try { + testOpts.addOptionChaining("port", "port", moe::Int, "Port") + .setImplicit(moe::Value("String")); + FAIL("Was able to register implicit value with wrong type"); + } + catch (::mongo::DBException &e) { + } } TEST(Registration, ComposableNotVector) { - moe::OptionsParser parser; - moe::Environment environment; + moe::OptionSection testOpts; + try { + testOpts.addOptionChaining("setParameter", "setParameter", moe::String, + "Multiple Values").composing(); + FAIL("Was able to register composable option with wrong type"); + } + catch (::mongo::DBException &e) { + } + } + TEST(Registration, ComposableWithImplicit) { moe::OptionSection testOpts; - ASSERT_NOT_OK(testOpts.addOption(moe::OptionDescription("setParameter", "setParameter", - moe::String, - "Multiple Values", true/*visible*/, - moe::Value()/*no default*/, - moe::Value()/*no implicit value*/, - true/*composing*/))); + try { + std::vector<std::string> implicitVal; + implicitVal.push_back("implicit"); + testOpts.addOptionChaining("setParameter", "setParameter", moe::StringVector, + "Multiple Values") + .setImplicit(moe::Value(implicitVal)) + .composing(); + FAIL("Was able to register composable option with implicit value"); + } + catch (::mongo::DBException &e) { + } + + try { + std::vector<std::string> implicitVal; + implicitVal.push_back("implicit"); + testOpts.addOptionChaining("setParameter", "setParameter", moe::StringVector, + "Multiple Values") + .composing() + .setImplicit(moe::Value(implicitVal)); + FAIL("Was able to set implicit value on composable option"); + } + catch (::mongo::DBException &e) { + } + } + + TEST(Registration, ComposableWithDefault) { + moe::OptionSection testOpts; + try { + std::vector<std::string> defaultVal; + defaultVal.push_back("default"); + testOpts.addOptionChaining("setParameter", "setParameter", moe::StringVector, + "Multiple Values") + .setDefault(moe::Value(defaultVal)) + .composing(); + FAIL("Was able to register composable option with default value"); + } + catch (::mongo::DBException &e) { + } + + try { + std::vector<std::string> defaultVal; + defaultVal.push_back("default"); + testOpts.addOptionChaining("setParameter", "setParameter", moe::StringVector, + "Multiple Values") + .composing() + .setDefault(moe::Value(defaultVal)); + FAIL("Was able to set default value on composable option"); + } + catch (::mongo::DBException &e) { + } } TEST(Parsing, Good) { @@ -101,8 +175,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -127,7 +201,7 @@ namespace { moe::OptionSection testOpts; moe::OptionSection subSection("Section Name"); - subSection.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + subSection.addOptionChaining("port", "port", moe::Int, "Port"); testOpts.addSection(subSection); std::vector<std::string> argv; @@ -149,8 +223,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("multival", "multival", moe::StringVector, - "Multiple Values")); + testOpts.addOptionChaining("multival", "multival", moe::StringVector, "Multiple Values"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -215,7 +288,7 @@ namespace { moe::OptionSection testOpts; testOpts.addPositionalOption(moe::PositionalOptionDescription("positional", moe::String)); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -241,8 +314,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("positional", "positional", moe::String, - "Positional")); + testOpts.addOptionChaining("positional", "positional", moe::String, + "Positional"); testOpts.addPositionalOption(moe::PositionalOptionDescription("positional", moe::String)); std::vector<std::string> argv; @@ -342,7 +415,7 @@ namespace { moe::OptionSection testOpts; testOpts.addPositionalOption(moe::PositionalOptionDescription("positional", moe::StringVector, 2)); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -372,8 +445,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -388,8 +461,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -405,8 +478,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -422,9 +495,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port", true, - moe::Value(5))); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port").setDefault(moe::Value(5)); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -443,9 +515,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port", true, - moe::Value(5))); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port").setDefault(moe::Value(5)); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -466,11 +537,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("val1", "val1", moe::Int, "Val1", true, - moe::Value(5))); - testOpts.addOption(moe::OptionDescription("val2", "val2", moe::Int, "Val2", true, - moe::Value(5))); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("val1", "val1", moe::Int, "Val1").setDefault(moe::Value(5)); + testOpts.addOptionChaining("val2", "val2", moe::Int, "Val2").setDefault(moe::Value(5)); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -489,10 +558,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port", true, - moe::Value(6), - moe::Value(7))); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port") + .setDefault(moe::Value(6)).setImplicit(moe::Value(7)); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -512,10 +580,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port", true, - moe::Value(6), - moe::Value(7))); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port") + .setDefault(moe::Value(6)).setImplicit(moe::Value(7)); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -534,10 +601,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port", true, - moe::Value(6), - moe::Value(7))); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port") + .setDefault(moe::Value(6)).setImplicit(moe::Value(7)); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -558,8 +624,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help,h", moe::Switch, "Display help")); - testOpts.addOption(moe::OptionDescription("port", "port,p", moe::Int, "Port")); + testOpts.addOptionChaining("help", "help,h", moe::Switch, "Display help"); + testOpts.addOptionChaining("port", "port,p", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -582,8 +648,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("opt", "opt,o", moe::Switch, "first opt")); - testOpts.addOption(moe::OptionDescription("arg", "arg,a", moe::Switch, "first arg")); + testOpts.addOptionChaining("opt", "opt,o", moe::Switch, "first opt"); + testOpts.addOptionChaining("arg", "arg,a", moe::Switch, "first arg"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -598,7 +664,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -613,7 +679,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("help", "help", moe::Switch, "Display help")); + testOpts.addOptionChaining("help", "help", moe::Switch, "Display help"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -633,13 +699,13 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - ASSERT_OK(testOpts.addOption(moe::OptionDescription("v", "verbose,v", moe::Switch, - "be more verbose (include multiple times for more verbosity e.g. -vvvvv)"))); + testOpts.addOptionChaining("v", "verbose,v", moe::Switch, + "be more verbose (include multiple times for more verbosity e.g. -vvvvv)"); /* support for -vv -vvvv etc. */ for (std::string s = "vv"; s.length() <= 12; s.append("v")) { - ASSERT_OK(testOpts.addOption(moe::OptionDescription(s.c_str(), s.c_str(), moe::Switch, - "higher verbosity levels (hidden)", false))); + testOpts.addOptionChaining(s.c_str(), s.c_str(), moe::Switch, + "higher verbosity levels (hidden)").hidden(); } std::vector<std::string> argv; @@ -668,9 +734,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -693,8 +758,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -712,9 +776,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -739,10 +802,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); - testOpts.addOption(moe::OptionDescription("str", "str", moe::String, "String")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); + testOpts.addOptionChaining("str", "str", moe::String, "String"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -766,12 +828,11 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("this", "this", moe::Switch, "This")); - testOpts.addOption(moe::OptionDescription("that", "that", moe::Switch, "That")); - testOpts.addOption(moe::OptionDescription("another", "another", moe::String, "Another")); - testOpts.addOption(moe::OptionDescription("other", "other", moe::String, "Other")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("this", "this", moe::Switch, "This"); + testOpts.addOptionChaining("that", "that", moe::Switch, "That"); + testOpts.addOptionChaining("another", "another", moe::String, "Another"); + testOpts.addOptionChaining("other", "other", moe::String, "Other"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -799,10 +860,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port", true, - moe::Value(5))); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port").setDefault(moe::Value(5)); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -825,9 +884,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -850,8 +908,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -869,8 +926,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -888,9 +944,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -916,8 +971,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -935,9 +989,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -955,9 +1008,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -975,9 +1027,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("nested.port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("nested.port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1000,9 +1051,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("dotted.port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("dotted.port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1025,10 +1075,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("dottednested.var1", "var1", moe::Int, "Var1")); - testOpts.addOption(moe::OptionDescription("dottednested.var2", "var2", moe::Int, "Var2")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("dottednested.var1", "var1", moe::Int, "Var1"); + testOpts.addOptionChaining("dottednested.var2", "var2", moe::Int, "Var2"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1056,10 +1105,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("multival", "multival", moe::StringVector, - "Multiple Values")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("multival", "multival", moe::StringVector, "Multiple Values"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1086,10 +1133,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("multival", "multival", moe::StringVector, - "Multiple Values")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("multival", "multival", moe::StringVector, "Multiple Values"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1109,8 +1154,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1162,10 +1206,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port", true, - moe::Value(5))); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port").setDefault(moe::Value(5)); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1190,8 +1232,7 @@ namespace { moe::OptionSection testOpts; // TODO: Should the error be in here? - testOpts.addOption(moe::OptionDescription("config", "config", - moe::Int, "Config file to parse")); + testOpts.addOptionChaining("config", "config", moe::Int, "Config file to parse"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1209,9 +1250,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1232,9 +1272,8 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1255,8 +1294,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1273,13 +1311,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("setParameter", "setParameter", moe::StringVector, - "Multiple Values", true/*visible*/, - moe::Value()/*no default*/, - moe::Value()/*no implicit value*/, - true/*composing*/)); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("setParameter", "setParameter", moe::StringVector, + "Multiple Values").composing(); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1315,13 +1349,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("setParameter", "setParameter", moe::StringVector, - "Multiple Values", true/*visible*/, - moe::Value()/*no default*/, - moe::Value()/*no implicit value*/, - true/*composing*/)); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("setParameter", "setParameter", moe::StringVector, + "Multiple Values").composing(); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1357,7 +1387,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1382,7 +1412,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1397,7 +1427,7 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1421,10 +1451,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); - testOpts.addOption(moe::OptionDescription("host", "host", moe::String, "Host")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); + testOpts.addOptionChaining("host", "host", moe::String, "Host"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1453,10 +1482,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); - testOpts.addOption(moe::OptionDescription("host", "host", moe::String, "Host")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); + testOpts.addOptionChaining("host", "host", moe::String, "Host"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1485,10 +1513,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); - testOpts.addOption(moe::OptionDescription("host", "host", moe::String, "Host")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); + testOpts.addOptionChaining("host", "host", moe::String, "Host"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1517,10 +1544,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); - testOpts.addOption(moe::OptionDescription("host", "host", moe::String, "Host")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); + testOpts.addOptionChaining("host", "host", moe::String, "Host"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1541,10 +1567,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); - testOpts.addOption(moe::OptionDescription("host", "host", moe::String, "Host")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); + testOpts.addOptionChaining("host", "host", moe::String, "Host"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1565,10 +1590,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); - testOpts.addOption(moe::OptionDescription("host", "host", moe::String, "Host")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); + testOpts.addOptionChaining("host", "host", moe::String, "Host"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1598,10 +1622,9 @@ namespace { moe::Environment environment; moe::OptionSection testOpts; - testOpts.addOption(moe::OptionDescription("config", "config", - moe::String, "Config file to parse")); - testOpts.addOption(moe::OptionDescription("port", "port", moe::Int, "Port")); - testOpts.addOption(moe::OptionDescription("host", "host", moe::String, "Host")); + testOpts.addOptionChaining("config", "config", moe::String, "Config file to parse"); + testOpts.addOptionChaining("port", "port", moe::Int, "Port"); + testOpts.addOptionChaining("host", "host", moe::String, "Host"); std::vector<std::string> argv; argv.push_back("binaryname"); @@ -1642,10 +1665,10 @@ namespace { sb << "filler" << i; testOpts.addOptionChaining(sb.str(), sb.str(), moe::String, "Filler Option"); } - moe::Value defaultVal("default"); - moe::Value implicitVal("implicit"); + moe::Value defaultVal(std::string("default")); + moe::Value implicitVal(std::string("implicit")); optionRef.hidden().setDefault(defaultVal); - optionRef.setImplicit(implicitVal).composing(); + optionRef.setImplicit(implicitVal); std::vector<moe::OptionDescription> options_vector; ASSERT_OK(testOpts.getAllOptions(&options_vector)); @@ -1661,7 +1684,7 @@ namespace { ASSERT_EQUALS(iterator->_isVisible, false); ASSERT_TRUE(iterator->_default.equal(defaultVal)); ASSERT_TRUE(iterator->_implicit.equal(implicitVal)); - ASSERT_EQUALS(iterator->_isComposing, true); + ASSERT_EQUALS(iterator->_isComposing, false); foundRef = true; } } @@ -1742,7 +1765,7 @@ namespace { OptionsParserTester parser; moe::Environment environment; - moe::Value defaultVal("default"); + moe::Value defaultVal(std::string("default")); moe::OptionSection testOpts; testOpts.addOptionChaining("default", @@ -1778,7 +1801,7 @@ namespace { OptionsParserTester parser; moe::Environment environment; - moe::Value implicitVal("implicit"); + moe::Value implicitVal(std::string("implicit")); moe::OptionSection testOpts; testOpts.addOptionChaining("implicit", diff --git a/src/mongo/util/options_parser/startup_options.h b/src/mongo/util/options_parser/startup_options.h index 926dc46daa6..d6e7e9763a1 100644 --- a/src/mongo/util/options_parser/startup_options.h +++ b/src/mongo/util/options_parser/startup_options.h @@ -40,10 +40,7 @@ namespace optionenvironment { * Example: * MONGO_MODULE_STARTUP_OPTIONS_REGISTER(MongodOptions)(InitializerContext* context) { * return addMongodOptions(&moe::startupOptions); - * ret = startupOptions.addOption(OD("option", "option", moe::String, "description")) - * if (!ret.isOK()) { - * return ret; - * } + * startupOptions.addOptionChaining("option", "option", moe::String, "description"); * return Status::OK(); * } */ |