diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/dbshell.cpp | 4 | ||||
-rw-r--r-- | shell/msvc/mongo.vcxproj | 7 | ||||
-rw-r--r-- | shell/msvc/mongo.vcxproj.filters | 24 | ||||
-rw-r--r-- | shell/servers.js | 17 | ||||
-rw-r--r-- | shell/shell_utils.cpp | 25 | ||||
-rw-r--r-- | shell/utils.js | 34 |
6 files changed, 85 insertions, 26 deletions
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp index bbec715729c..5984c70537f 100644 --- a/shell/dbshell.cpp +++ b/shell/dbshell.cpp @@ -122,7 +122,7 @@ void shellHistoryInit(){ rl_attempted_completion_function = completionHook; #else - cout << "type \"exit\" to exit" << endl; + //cout << "type \"exit\" to exit" << endl; #endif } void shellHistoryDone(){ @@ -491,7 +491,7 @@ int _main(int argc, char* argv[]) { mongo::UnitTest::runTests(); if ( !nodb ) { // connect to db - if ( ! mongo::cmdLine.quiet ) cout << "url: " << url << endl; + //if ( ! mongo::cmdLine.quiet ) cout << "url: " << url << endl; stringstream ss; if ( mongo::cmdLine.quiet ) diff --git a/shell/msvc/mongo.vcxproj b/shell/msvc/mongo.vcxproj index 7a4f4194c18..0c39df9f883 100644 --- a/shell/msvc/mongo.vcxproj +++ b/shell/msvc/mongo.vcxproj @@ -219,6 +219,13 @@ </ItemGroup>
<ItemGroup>
<None Include="..\..\SConstruct" />
+ <None Include="..\collection.js" />
+ <None Include="..\db.js" />
+ <None Include="..\mongo.js" />
+ <None Include="..\mr.js" />
+ <None Include="..\query.js" />
+ <None Include="..\servers.js" />
+ <None Include="..\utils.js" />
<None Include="mongo.ico" />
</ItemGroup>
<ItemGroup>
diff --git a/shell/msvc/mongo.vcxproj.filters b/shell/msvc/mongo.vcxproj.filters index 5b56c342507..c31dd8ca37a 100644 --- a/shell/msvc/mongo.vcxproj.filters +++ b/shell/msvc/mongo.vcxproj.filters @@ -33,6 +33,9 @@ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
+ <Filter Include="_js files">
+ <UniqueIdentifier>{473e7192-9f2a-47c5-ad95-e5b75d4f48f9}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\dbshell.cpp">
@@ -216,6 +219,27 @@ <None Include="mongo.ico">
<Filter>Resource Files</Filter>
</None>
+ <None Include="..\collection.js">
+ <Filter>_js files</Filter>
+ </None>
+ <None Include="..\db.js">
+ <Filter>_js files</Filter>
+ </None>
+ <None Include="..\mongo.js">
+ <Filter>_js files</Filter>
+ </None>
+ <None Include="..\mr.js">
+ <Filter>_js files</Filter>
+ </None>
+ <None Include="..\query.js">
+ <Filter>_js files</Filter>
+ </None>
+ <None Include="..\servers.js">
+ <Filter>_js files</Filter>
+ </None>
+ <None Include="..\utils.js">
+ <Filter>_js files</Filter>
+ </None>
</ItemGroup>
<ItemGroup>
<Library Include="..\..\..\js\js32d.lib" />
diff --git a/shell/servers.js b/shell/servers.js index df412922afa..78b25ae255d 100644 --- a/shell/servers.js +++ b/shell/servers.js @@ -94,10 +94,11 @@ startMongos = function(){ return startMongoProgram.apply( null, createMongoArgs( "mongos" , arguments ) ); } -// Start a mongo program instance (generally mongod or mongos) and return a -// 'Mongo' object connected to it. This function's first argument is the -// program name, and subsequent arguments to this function are passed as -// command line arguments to the program. +/* Start mongod or mongos and return a Mongo() object connected to there. + This function's first argument is "mongod" or "mongos" program name, \ + and subsequent arguments to this function are passed as + command line arguments to the program. +*/ startMongoProgram = function(){ var port = _parsePort.apply( null, arguments ); @@ -132,15 +133,15 @@ myPort = function() { return 27017; } -ShardingTest = function( testName , numServers , verboseLevel , numMongos , otherParams ){ +ShardingTest = function( testName , numShards , verboseLevel , numMongos , otherParams ){ if ( ! otherParams ) otherParams = {} this._connections = []; - if ( otherParams.sync && numServers < 3 ) + if ( otherParams.sync && numShards < 3 ) throw "if you want sync, you need at least 3 servers"; - for ( var i=0; i<numServers; i++){ + for ( var i=0; i<numShards; i++){ var conn = startMongodTest( 30000 + i , testName + i ); this._connections.push( conn ); } @@ -593,7 +594,6 @@ ToolTest.prototype.runTool = function(){ runMongoProgram.apply( null , a ); } - ReplTest = function( name, ports ){ this.name = name; this.ports = ports || allocatePorts( 2 ); @@ -614,7 +614,6 @@ ReplTest.prototype.getPath = function( master ){ return p; } - ReplTest.prototype.getOptions = function( master , extra , putBinaryFirst, norepl ){ if ( ! extra ) diff --git a/shell/shell_utils.cpp b/shell/shell_utils.cpp index d8308e26208..613c8b18fa3 100644 --- a/shell/shell_utils.cpp +++ b/shell/shell_utils.cpp @@ -115,7 +115,10 @@ namespace mongo { #ifndef MONGO_SAFE_SHELL - BSONObj listFiles(const BSONObj& args){ + BSONObj listFiles(const BSONObj& _args){ + static BSONObj cd = BSON( "0" << "." ); + BSONObj args = _args.isEmpty() ? cd : _args; + uassert( 10257 , "need to specify 1 argument to listFiles" , args.nFields() == 1 ); BSONObjBuilder lst; @@ -159,6 +162,24 @@ namespace mongo { return ret.obj(); } + BSONObj ls(const BSONObj& args) { + BSONObj o = listFiles(args); + if( !o.isEmpty() ) { + for( BSONObj::iterator i = o.firstElement().Obj().begin(); i.more(); ) { + BSONObj f = i.next().Obj(); + cout << f["name"].String(); + if( f["isDirectory"].trueValue() ) cout << '/'; + cout << '\n'; + } + cout.flush(); + } + return BSONObj(); + } + + BSONObj pwd(const BSONObj&) { + boost::filesystem::path p = boost::filesystem::current_path(); + return BSON( "" << p.string() ); + } BSONObj removeFile(const BSONObj& args){ uassert( 12597 , "need to specify 1 argument to listFiles" , args.nFields() == 1 ); @@ -694,6 +715,8 @@ namespace mongo { //can't access filesystem scope.injectNative( "removeFile" , removeFile ); scope.injectNative( "listFiles" , listFiles ); + scope.injectNative( "ls" , ls ); + scope.injectNative( "pwd", pwd ); scope.injectNative( "resetDbpath", ResetDbpath ); scope.injectNative( "copyDbpath", CopyDbpath ); #endif diff --git a/shell/utils.js b/shell/utils.js index c42f31c910c..f28508058a3 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -769,20 +769,26 @@ shellHelper = function( command , rest , shouldPrint ){ shellPrintHelper( res ); } return res; -} - -help = shellHelper.help = function(){ - print( "HELP" ); - print( "\t" + "show dbs show database names"); - print( "\t" + "show collections show collections in current database"); - print( "\t" + "show users show users in current database"); - print( "\t" + "show profile show most recent system.profile entries with time >= 1ms"); - print( "\t" + "use <db name> set curent database to <db name>" ); - print( "\t" + "db.help() help on DB methods"); - print( "\t" + "db.foo.help() help on collection methods"); - print( "\t" + "db.foo.find() list objects in collection foo" ); - print( "\t" + "db.foo.find( { a : 1 } ) list objects in foo where a == 1" ); - print( "\t" + "it result of the last line evaluated; use to further iterate"); +}
+
+help = shellHelper.help = function (x) {
+ if (x=="more") {
+ print("\tls()");
+ print("\tpwd()");
+ print("\tlistFiles()");
+ return;
+ }
+ print("\t" + "show dbs show database names");
+ print("\t" + "show collections show collections in current database");
+ print("\t" + "show users show users in current database");
+ print("\t" + "show profile show most recent system.profile entries with time >= 1ms");
+ print("\t" + "use <db name> set curent database to <db name>");
+ print("\t" + "db.help() help on DB methods");
+ print("\t" + "db.foo.help() help on collection methods");
+ print("\t" + "db.foo.find() list objects in collection foo");
+ print("\t" + "db.foo.find( { a : 1 } ) list objects in foo where a == 1");
+ print("\t" + "it result of the last line evaluated; use to further iterate");
+ print("\t" + "exit quit the mongo shell");
} shellHelper.use = function( dbname ){ |