summaryrefslogtreecommitdiff
path: root/shell/utils.js
diff options
context:
space:
mode:
authorDwight <dwight@10gen.com>2011-09-26 09:07:21 -0400
committerDwight <dwight@10gen.com>2011-09-26 09:07:21 -0400
commit31f83055750d68b123bd113d537d37ea81987192 (patch)
tree7f8fb499c4b4eae18d232c4fc48fc12828a51338 /shell/utils.js
parent4da8449ee2d8abf6ae7ba62441fce2013c4bd08a (diff)
parent5238cccca6ce47f9b427ace48cd57a4fa225ba74 (diff)
downloadmongo-31f83055750d68b123bd113d537d37ea81987192.tar.gz
Merge branch 'master' of github.com:mongodb/mongo
Diffstat (limited to 'shell/utils.js')
-rw-r--r--shell/utils.js43
1 files changed, 35 insertions, 8 deletions
diff --git a/shell/utils.js b/shell/utils.js
index 605934b9760..dc9383ba270 100644
--- a/shell/utils.js
+++ b/shell/utils.js
@@ -1,5 +1,7 @@
__quiet = false;
__magicNoPrint = { __magicNoPrint : 1111 }
+__callLastError = false;
+_verboseShell = false;
chatty = function(s){
if ( ! __quiet )
@@ -38,6 +40,16 @@ printStackTrace = function(){
}
}
+/**
+ * <p> Set the shell verbosity. If verbose the shell will display more information about command results. </>
+ * <p> Default is off. <p>
+ * @param {Bool} verbosity on / off
+ */
+setVerboseShell = function( value ) {
+ if( value == undefined ) value = true;
+ _verboseShell = value;
+}
+
doassert = function (msg) {
if (msg.indexOf("assert") == 0)
print(msg);
@@ -1005,16 +1017,15 @@ testLog = function(x){
}
shellPrintHelper = function (x) {
-
if (typeof (x) == "undefined") {
-
- if (typeof (db) != "undefined" && db.getLastError) {
+ if (__callLastError) {
+ __callLastError = false;
// explicit w:1 so that replset getLastErrorDefaults aren't used here which would be bad.
- var e = db.getLastError(1);
- if (e != null)
- print(e);
+ var err = db.getLastError(1);
+ if (err != null) {
+ print(err);
+ }
}
-
return;
}
@@ -1168,6 +1179,22 @@ shellHelper.use = function (dbname) {
print("switched to db " + db.getName());
}
+shellHelper.set = function (str) {
+ if (str == "") {
+ print("bad use parameter");
+ return;
+ }
+ tokens = str.split(" ");
+ param = tokens[0];
+ value = tokens[1];
+
+ if( value == undefined ) value = true;
+ if (param == "verbose") {
+ _verboseShell = value;
+ }
+ print("set " + param + " to " + value);
+}
+
shellHelper.it = function(){
if ( typeof( ___it___ ) == "undefined" || ___it___ == null ){
print( "no cursor" );
@@ -1460,7 +1487,7 @@ rs.help = function () {
print("\tan error, even if the command succeeds.");
print("\tsee also http://<mongod_host>:28017/_replSet for additional diagnostic info");
}
-rs.slaveOk = function () { return db.getMongo().setSlaveOk(); }
+rs.slaveOk = function (value) { return db.getMongo().setSlaveOk(value); }
rs.status = function () { return db._adminCommand("replSetGetStatus"); }
rs.isMaster = function () { return db.isMaster(); }
rs.initiate = function (c) { return db._adminCommand({ replSetInitiate: c }); }