print help if you don't give a namespace

This commit is contained in:
Mike Dirolf 2009-06-25 16:15:15 -04:00
parent efe8911ecc
commit c8c17ed3eb
3 changed files with 16 additions and 3 deletions

View File

@ -34,6 +34,11 @@ mongo::Tool::~Tool(){
void mongo::Tool::printExtraHelp( ostream & out ){
}
void mongo::Tool::printHelp(ostream &out) {
_options->print(out);
printExtraHelp(out);
}
int mongo::Tool::main( int argc , char ** argv ){
boost::filesystem::path::default_name_check( boost::filesystem::no_check );
@ -44,8 +49,7 @@ int mongo::Tool::main( int argc , char ** argv ){
po::notify( _params );
if ( _params.count( "help" ) ){
_options->print( cerr );
printExtraHelp( cerr );
printHelp(cerr);
return 0;
}

View File

@ -50,6 +50,8 @@ namespace mongo {
virtual int run() = 0;
virtual void printHelp(ostream &out);
virtual void printExtraHelp( ostream & out );
protected:

View File

@ -44,7 +44,7 @@ public:
}
int run(){
const string ns = getNS();
string ns;
const bool csv = hasParam( "csv" );
ostream *outPtr = &cout;
string outfile = getParam( "out" );
@ -57,6 +57,13 @@ public:
vector<string> fields;
try {
ns = getNS();
} catch (...) {
printHelp(cerr);
return 1;
}
if ( hasParam( "fields" ) ){
BSONObjBuilder b;