0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-29 00:32:18 +01:00

CS-1535: Avoid writing to stderr unless dumping to stdout

This commit is contained in:
Brandon Diamond 2011-10-28 16:28:25 -04:00
parent 8a79e63cbc
commit 1ffc5fd9e5

View File

@ -37,7 +37,7 @@ class Dump : public Tool {
FILE* _f;
};
public:
Dump() : Tool( "dump" , ALL , "*" , "*" , false ) {
Dump() : Tool( "dump" , ALL , "*" , "*" , true ) {
add_options()
("out,o", po::value<string>()->default_value("dump"), "output directory or \"-\" for stdout")
("query,q", po::value<string>() , "json query" )
@ -47,6 +47,15 @@ public:
;
}
virtual void preSetup() {
string out = getParam("out");
if ( out == "-" ) {
// write output to standard error to avoid mangling output
// must happen early to avoid sending junk to stdout
useStandardOutput(false);
}
}
virtual void printExtraHelp(ostream& out) {
out << "Export MongoDB data to BSON files.\n" << endl;
}