summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMike Dirolf <mike@10gen.com>2009-09-01 16:52:50 -0400
committerMike Dirolf <mike@10gen.com>2009-09-01 16:52:50 -0400
commit4cc0e1183486880c9d37f6cb25f8080e25d58ed7 (patch)
tree0ca0bd34c03a1a34c88559614243a9c8ff9fdbae /tools
parent71f76d998c2068a0bba2704c23fd085b4a6636bc (diff)
downloadmongo-4cc0e1183486880c9d37f6cb25f8080e25d58ed7.tar.gz
tools: support for -vvvv, use same options style as mongod and mongo
Diffstat (limited to 'tools')
-rw-r--r--tools/Tool.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/Tool.cpp b/tools/Tool.cpp
index 851488cbfb4..64613221271 100644
--- a/tools/Tool.cpp
+++ b/tools/Tool.cpp
@@ -29,6 +29,11 @@ mongo::Tool::Tool( string name , string defaultDB , string defaultCollection ) :
;
_hidden_options = new po::options_description( name + " hidden options" );
+
+ /* support for -vv -vvvv etc. */
+ for (string s = "vv"; s.length() <= 10; s.append("v")) {
+ _hidden_options->add_options()(s.c_str(), "verbose");
+ }
}
mongo::Tool::~Tool(){
@@ -51,13 +56,19 @@ int mongo::Tool::main( int argc , char ** argv ){
_name = argv[0];
+ /* using the same style as db.cpp */
+ int command_line_style = (((po::command_line_style::unix_style ^
+ po::command_line_style::allow_guessing) |
+ po::command_line_style::allow_long_disguise) ^
+ po::command_line_style::allow_sticky);
try {
po::options_description all_options("all options");
all_options.add(*_options).add(*_hidden_options);
po::store( po::command_line_parser( argc , argv ).
options(all_options).
- positional( _positonalOptions ).run() , _params );
+ positional( _positonalOptions ).
+ style(command_line_style).run() , _params );
po::notify( _params );
} catch (po::error &e) {
@@ -71,8 +82,15 @@ int mongo::Tool::main( int argc , char ** argv ){
return 0;
}
- if ( _params.count( "verbose" ) )
+ if ( _params.count( "verbose" ) ) {
logLevel = 1;
+ }
+
+ for (string s = "vv"; s.length() <= 10; s.append("v")) {
+ if (_params.count(s)) {
+ logLevel = s.length();
+ }
+ }
if ( ! hasParam( "dbpath" ) ) {
_host = "127.0.0.1";