diff options
author | Shaun Verch <shaun.verch@10gen.com> | 2013-10-22 21:32:36 -0400 |
---|---|---|
committer | Shaun Verch <shaun.verch@10gen.com> | 2013-10-23 19:41:30 -0400 |
commit | 26f1aa281843b901219c49ad5f35e69fe4119bac (patch) | |
tree | bf37bde346e4f08118c35ad65d1ba6157096574f /src/mongo/util/options_parser/option_description.cpp | |
parent | 4686f81fe1ad2dc700ab17748d96e9c24f824579 (diff) | |
download | mongo-26f1aa281843b901219c49ad5f35e69fe4119bac.tar.gz |
SERVER-11144 Add positional options to chaining interface
Diffstat (limited to 'src/mongo/util/options_parser/option_description.cpp')
-rw-r--r-- | src/mongo/util/options_parser/option_description.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mongo/util/options_parser/option_description.cpp b/src/mongo/util/options_parser/option_description.cpp index a98b33f1d6c..1a439c99c5b 100644 --- a/src/mongo/util/options_parser/option_description.cpp +++ b/src/mongo/util/options_parser/option_description.cpp @@ -172,5 +172,29 @@ namespace optionenvironment { return *this; } + OptionDescription& OptionDescription::positional(int start, int end) { + + if (start < 1 || (end < 1 && end != -1) || (end != -1 && end < start)) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "Invalid positional specification: \"start\": " << start << ", \"end\": " << end; + throw DBException(sb.str(), ErrorCodes::InternalError); + } + + if ((end - start) > 0) { + if (_type != StringVector) { + StringBuilder sb; + sb << "Could not register option \"" << _dottedName << "\": " + << "Positional range implies that multiple values are allowed, " + << "but option is not registered as type StringVector"; + throw DBException(sb.str(), ErrorCodes::InternalError); + } + } + + _positionalStart = start; + _positionalEnd = end; + return *this; + } + } // namespace optionenvironment } // namespace mongo |