diff options
Diffstat (limited to 'tools/tool.cpp')
-rw-r--r-- | tools/tool.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/tools/tool.cpp b/tools/tool.cpp index dbb3de140e9..5887d2ea810 100644 --- a/tools/tool.cpp +++ b/tools/tool.cpp @@ -35,7 +35,7 @@ namespace mongo { CmdLine cmdLine; - Tool::Tool( string name , bool localDBAllowed , string defaultDB , + Tool::Tool( string name , DBAccess access , string defaultDB , string defaultCollection , bool usesstdout ) : _name( name ) , _db( defaultDB ) , _coll( defaultCollection ) , _usesstdout(usesstdout), _noconnection(false), _autoreconnect(false), _conn(0), _paired(false) { @@ -44,15 +44,21 @@ namespace mongo { _options->add_options() ("help","produce help message") ("verbose,v", "be more verbose (include multiple times for more verbosity e.g. -vvvvv)") - ("host,h",po::value<string>(), "mongo host to connect to (\"left,right\" for pairs)" ) - ("port",po::value<string>(), "server port. Can also use --host hostname:port" ) - ("db,d",po::value<string>(), "database to use" ) - ("collection,c",po::value<string>(), "collection to use (some commands)" ) - ("username,u",po::value<string>(), "username" ) - ("password,p", new PasswordValue( &_password ), "password" ) - ("ipv6", "enable IPv6 support (disabled by default)") ; - if ( localDBAllowed ) + + if ( access == ALL || access == NO_LOCAL){ + _options->add_options() + ("host,h",po::value<string>(), "mongo host to connect to (\"left,right\" for pairs)" ) + ("port",po::value<string>(), "server port. Can also use --host hostname:port" ) + ("db,d",po::value<string>(), "database to use" ) + ("collection,c",po::value<string>(), "collection to use (some commands)" ) + ("username,u",po::value<string>(), "username" ) + ("password,p", new PasswordValue( &_password ), "password" ) + ("ipv6", "enable IPv6 support (disabled by default)") + ; + } + + if ( access == ALL ) { _options->add_options() ("dbpath",po::value<string>(), "directly access mongod database " "files in the given path, instead of connecting to a mongod " @@ -60,6 +66,7 @@ namespace mongo { "used if a mongod is currently accessing the same path" ) ("directoryperdb", "if dbpath specified, each db is in a separate directory" ) ; + } _hidden_options = new po::options_description( name + " hidden options" ); @@ -307,8 +314,8 @@ namespace mongo { throw UserException( 9997 , (string)"auth failed: " + errmsg ); } - BSONTool::BSONTool( const char * name , bool objcheck ) - : Tool( name , true , "" , "" ) , _objcheck( objcheck ){ + BSONTool::BSONTool( const char * name, DBAccess access , bool objcheck ) + : Tool( name , access , "" , "" ) , _objcheck( objcheck ){ add_options() ("objcheck" , "validate object before inserting" ) |