diff options
author | Aaron <aaron@10gen.com> | 2009-02-13 14:35:03 -0500 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-02-13 14:35:03 -0500 |
commit | 851b91a4d3b76b096134a5ce6d62453b8a3b6bf4 (patch) | |
tree | a8e19e09919f99e7908552be993f4ffa6766649f /shell/mongo.js | |
parent | 1fe2b0cdb3d7a9d5cbecbd7bdec51347c2b2ce47 (diff) | |
download | mongo-851b91a4d3b76b096134a5ce6d62453b8a3b6bf4.tar.gz |
Don't expect dbpath parameter for non-mongod programs
Diffstat (limited to 'shell/mongo.js')
-rw-r--r-- | shell/mongo.js | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/shell/mongo.js b/shell/mongo.js index 38c2181c2da..aafa9cc5d16 100644 --- a/shell/mongo.js +++ b/shell/mongo.js @@ -64,25 +64,35 @@ connect = function( url , user , pass ){ return db; } -_portAndDbpath = function() { - var port = ""; +_parsePath = function() { var dbpath = ""; for( var i = 0; i < arguments.length; ++i ) - if ( arguments[ i ] == "--port" ) - port = arguments[ i + 1 ]; - else if ( arguments[ i ] == "--dbpath" ) + if ( arguments[ i ] == "--dbpath" ) dbpath = arguments[ i + 1 ]; - if ( port == "" || dbpath == "" ) - throw "Invalid command line options"; + if ( dbpath == "" ) + throw "No dbpath specified"; + + return dbpath; +} + +_parsePort = function() { + var port = ""; + for( var i = 0; i < arguments.length; ++i ) + if ( arguments[ i ] == "--port" ) + port = arguments[ i + 1 ]; - return { port: port, dbpath: dbpath }; + if ( port == "" ) + throw "No port specified"; + return port; } // Start a mongod instance and return a 'Mongo' object connected to it. // This function's arguments are passed as command line arguments to mongod. // The specified 'dbpath' is cleared if it exists, created if not. startMongod = function() { + var dbpath = _parsePath.apply( null, arguments ); + resetDbpath( dbpath ); var fullArgs = Array(); fullArgs[ 0 ] = "mongod"; for( i = 0; i < arguments.length; ++i ) @@ -96,14 +106,12 @@ startMongod = function() { // command line arguments to the program. The specified 'dbpath' is cleared if // it exists, created if not. startMongoProgram = function() { - var dbpath = _portAndDbpath.apply( null, arguments ).dbpath; - resetDbpath( dbpath ); return startMongoProgramNoReset.apply( null, arguments ); } // Same as startMongoProgram, but uses existing files in dbpath startMongoProgramNoReset = function() { - var port = _portAndDbpath.apply( null, arguments ).port; + var port = _parsePort.apply( null, arguments ); _startMongoProgram.apply( null, arguments ); |