summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRichard Kreuter <richard@10gen.com>2011-03-17 15:34:19 -0400
committerRichard Kreuter <richard@10gen.com>2011-03-17 15:34:40 -0400
commitc31719663ee0ae75d42ac0db429f1ac762b46b41 (patch)
treeb9f7f3e1b0ad65453256df7e93352d7201007831 /tools
parent550850e719624dd1aae6a8a41c61970795ab8359 (diff)
downloadmongo-c31719663ee0ae75d42ac0db429f1ac762b46b41.tar.gz
SERVER-2691.
Diffstat (limited to 'tools')
-rw-r--r--tools/tool.cpp13
-rw-r--r--tools/tool.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/tools/tool.cpp b/tools/tool.cpp
index f687269cf00..92a4bd45b1c 100644
--- a/tools/tool.cpp
+++ b/tools/tool.cpp
@@ -25,6 +25,7 @@
#include "util/file_allocator.h"
#include "util/password.h"
+#include "util/version.h"
using namespace std;
using namespace mongo;
@@ -44,6 +45,7 @@ namespace mongo {
_options->add_options()
("help","produce help message")
("verbose,v", "be more verbose (include multiple times for more verbosity e.g. -vvvvv)")
+ ("version", "print the program's version and exit" )
;
if ( access & REMOTE_SERVER )
@@ -92,6 +94,12 @@ namespace mongo {
printExtraHelpAfter(out);
}
+ void Tool::printVersion(ostream &out) {
+ out << _name << " version " << mongo::versionString;
+ if (mongo::versionString[strlen(mongo::versionString)-1] == '-')
+ out << " (commit " << mongo::gitVersion() << ")";
+ out << endl;
+ }
int Tool::main( int argc , char ** argv ) {
static StaticObserver staticObserver;
@@ -146,6 +154,11 @@ namespace mongo {
return 0;
}
+ if ( _params.count( "version" ) ) {
+ printVersion(cout);
+ return 0;
+ }
+
if ( _params.count( "verbose" ) ) {
logLevel = 1;
}
diff --git a/tools/tool.h b/tools/tool.h
index f6124b87b6c..fd3403dcb16 100644
--- a/tools/tool.h
+++ b/tools/tool.h
@@ -92,6 +92,8 @@ namespace mongo {
virtual void printExtraHelp( ostream & out ) {}
virtual void printExtraHelpAfter( ostream & out ) {}
+ virtual void printVersion(ostream &out);
+
protected:
mongo::DBClientBase &conn( bool slaveIfPaired = false );