summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-01-28 10:25:16 -0500
committerAaron <aaron@10gen.com>2009-01-28 10:25:16 -0500
commitd3e776d48b4d9f86fa8d18118a82a43020bc03df (patch)
tree8a6446faa9f2c33da41cc87ef9a4b78eb4e93213 /shell
parent19208c3ae1c319352c83df283f66e5d6d840a558 (diff)
downloadmongo-d3e776d48b4d9f86fa8d18118a82a43020bc03df.tar.gz
Add 'nodb' arg to shell
Diffstat (limited to 'shell')
-rw-r--r--shell/dbshell.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp
index 03689356452..5073ded8aa6 100644
--- a/shell/dbshell.cpp
+++ b/shell/dbshell.cpp
@@ -44,7 +44,8 @@ int main(int argc, char* argv[]) {
string password;
bool runShell = false;
-
+ bool nodb = false;
+
int argNumber = 1;
for ( ; argNumber < argc; argNumber++) {
const char* str = argv[argNumber];
@@ -54,6 +55,11 @@ int main(int argc, char* argv[]) {
continue;
}
+ if (strcmp(str, "--nodb") == 0) {
+ nodb = true;
+ continue;
+ }
+
if ( strcmp( str , "-u" ) == 0 ){
username = argv[argNumber+1];
argNumber++;
@@ -76,7 +82,7 @@ int main(int argc, char* argv[]) {
strcmp(str, "-h" ) == 0 ) {
cout
- << "usage: " << argv[0] << " [options] <db address> [file names]\n"
+ << "usage: " << argv[0] << " [options] [db address] [file names]\n"
<< "db address can be:\n"
<< " foo = foo database on local machine\n"
<< " 192.169.0.5/foo = foo database on 192.168.0.5 machine\n"
@@ -85,6 +91,7 @@ int main(int argc, char* argv[]) {
<< " --shell run the shell after executing files\n"
<< " -u <username>\n"
<< " -p<password> - notice no space\n"
+ << " --nodb don't connect to mongod on startup. No 'db address' arg expected.\n"
<< "file names: a list of files to run. will exit after unless --shell is specified\n"
;
@@ -100,7 +107,9 @@ int main(int argc, char* argv[]) {
continue;
}
- {
+ if ( nodb )
+ break;
+ else {
const char * last = strstr( str , "/" );
if ( last )
last++;
@@ -117,7 +126,7 @@ int main(int argc, char* argv[]) {
break;
}
- { // init mongo code
+ if ( !nodb ) { // init mongo code
v8::HandleScope handle_scope;
string setup = (string)"db = connect( \"" + host + "\")";
if ( ! ExecuteString( v8::String::New( setup.c_str() ) , v8::String::New( "(connect)" ) , false , true ) ){