diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2018-01-29 11:23:25 -0500 |
---|---|---|
committer | Billy Donahue <billy.donahue@mongodb.com> | 2018-01-30 13:13:42 -0500 |
commit | 0700f1dc9c9f9985962d96f6aef6200a3a5bd57d (patch) | |
tree | c4ba664c23e14cff59d94f9676601087f22d5e33 /src/mongo | |
parent | f4215c128856ab315c9d3f3a25a5b9ec63269ebf (diff) | |
download | mongo-0700f1dc9c9f9985962d96f6aef6200a3a5bd57d.tar.gz |
SERVER-32958 Command::help() returns std::string
Diffstat (limited to 'src/mongo')
142 files changed, 665 insertions, 666 deletions
diff --git a/src/mongo/db/auth/sasl_commands.cpp b/src/mongo/db/auth/sasl_commands.cpp index 0d762e5e38c..433439ad2b8 100644 --- a/src/mongo/db/auth/sasl_commands.cpp +++ b/src/mongo/db/auth/sasl_commands.cpp @@ -77,7 +77,7 @@ public: const BSONObj& cmdObj, BSONObjBuilder& result); - virtual void help(stringstream& help) const; + virtual std::string help() const override; virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } @@ -103,7 +103,7 @@ public: const BSONObj& cmdObj, BSONObjBuilder& result); - virtual void help(stringstream& help) const; + std::string help() const override; virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } @@ -254,8 +254,8 @@ Status doSaslContinue(const Client* client, CmdSaslStart::CmdSaslStart() : BasicCommand(saslStartCommandName) {} CmdSaslStart::~CmdSaslStart() {} -void CmdSaslStart::help(std::stringstream& os) const { - os << "First step in a SASL authentication conversation."; +std::string CmdSaslStart::help() const { + return "First step in a SASL authentication conversation."; } void CmdSaslStart::redactForLogging(mutablebson::Document* cmdObj) { @@ -301,8 +301,8 @@ bool CmdSaslStart::run(OperationContext* opCtx, CmdSaslContinue::CmdSaslContinue() : BasicCommand(saslContinueCommandName) {} CmdSaslContinue::~CmdSaslContinue() {} -void CmdSaslContinue::help(std::stringstream& os) const { - os << "Subsequent steps in a SASL authentication conversation."; +std::string CmdSaslContinue::help() const { + return "Subsequent steps in a SASL authentication conversation."; } bool CmdSaslContinue::run(OperationContext* opCtx, diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp index 439a4783822..24292e6a3c8 100644 --- a/src/mongo/db/commands.cpp +++ b/src/mongo/db/commands.cpp @@ -53,6 +53,7 @@ #include "mongo/s/stale_exception.h" #include "mongo/util/invariant.h" #include "mongo/util/log.h" +#include "mongo/util/mongoutils/str.h" namespace mongo { @@ -341,10 +342,6 @@ Command::Command(StringData name, StringData oldName) globalCommandRegistry()->registerCommand(this, name, oldName); } -void Command::help(std::stringstream& help) const { - help << "no help defined"; -} - Status Command::explain(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, @@ -466,12 +463,9 @@ bool Command::publicRun(OperationContext* opCtx, void Command::generateHelpResponse(OperationContext* opCtx, rpc::ReplyBuilderInterface* replyBuilder, const Command& command) { - std::stringstream ss; BSONObjBuilder helpBuilder; - ss << "help for: " << command.getName() << " "; - command.help(ss); - helpBuilder.append("help", ss.str()); - + helpBuilder.append("help", + str::stream() << "help for: " << command.getName() << " " << command.help()); replyBuilder->setCommandReply(helpBuilder.obj()); replyBuilder->setMetadata(rpc::makeEmptyMetadata()); } diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index dc8b3fbf15c..f1e580b69f8 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -292,7 +292,9 @@ public: /** * Generates help text for this command. */ - virtual void help(std::stringstream& help) const; + virtual std::string help() const { + return "no help defined"; + } /** * Commands which can be explained override this method. Any operation which has a query diff --git a/src/mongo/db/commands/apply_ops_cmd.cpp b/src/mongo/db/commands/apply_ops_cmd.cpp index 81f4aa49f34..f2b41250973 100644 --- a/src/mongo/db/commands/apply_ops_cmd.cpp +++ b/src/mongo/db/commands/apply_ops_cmd.cpp @@ -210,9 +210,9 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "internal (sharding)\n{ applyOps : [ ] , preCondition : [ { ns : ... , q : ... , " - "res : ... } ] }"; + std::string help() const override { + return "internal (sharding)\n{ applyOps : [ ] , preCondition : [ { ns : ... , q : ... , " + "res : ... } ] }"; } Status checkAuthForOperation(OperationContext* opCtx, diff --git a/src/mongo/db/commands/authentication_commands.cpp b/src/mongo/db/commands/authentication_commands.cpp index 690f75ee89f..58e34b87f9d 100644 --- a/src/mongo/db/commands/authentication_commands.cpp +++ b/src/mongo/db/commands/authentication_commands.cpp @@ -101,8 +101,8 @@ public: return true; } - void help(stringstream& h) const final { - h << "internal"; + std::string help() const final { + return "internal"; } bool supportsWriteConcern(const BSONObj& cmd) const final { @@ -265,8 +265,8 @@ public: virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector<Privilege>* out) {} // No auth required - void help(stringstream& h) const { - h << "de-authenticate"; + std::string help() const override { + return "de-authenticate"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; diff --git a/src/mongo/db/commands/authentication_commands.h b/src/mongo/db/commands/authentication_commands.h index c40d8a3d4d1..a5123fb932b 100644 --- a/src/mongo/db/commands/authentication_commands.h +++ b/src/mongo/db/commands/authentication_commands.h @@ -43,8 +43,8 @@ public: virtual bool slaveOk() const { return true; } - virtual void help(std::stringstream& ss) const { - ss << "internal"; + std::string help() const override { + return "internal"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; diff --git a/src/mongo/db/commands/clone.cpp b/src/mongo/db/commands/clone.cpp index 31119edc849..e7ec4973221 100644 --- a/src/mongo/db/commands/clone.cpp +++ b/src/mongo/db/commands/clone.cpp @@ -65,9 +65,9 @@ public: return true; } - virtual void help(stringstream& help) const { - help << "clone this database from an instance of the db on another host\n"; - help << "{clone: \"host13\"[, slaveOk: <bool>]}"; + std::string help() const override { + return "clone this database from an instance of the db on another host\n" + "{clone: \"host13\"[, slaveOk: <bool>]}"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/clone_collection.cpp b/src/mongo/db/commands/clone_collection.cpp index f152b97213d..0a8ddde8bea 100644 --- a/src/mongo/db/commands/clone_collection.cpp +++ b/src/mongo/db/commands/clone_collection.cpp @@ -95,12 +95,12 @@ public: return Status::OK(); } - virtual void help(stringstream& help) const { - help << "{ cloneCollection: <collection>, from: <host> [,query: <query_filter>] " - "[,copyIndexes:<bool>] }" - "\nCopies a collection from one server to another. Do not use on a single server " - "as the destination " - "is placed at the same db.collection (namespace) as the source.\n"; + std::string help() const override { + return "{ cloneCollection: <collection>, from: <host> [,query: <query_filter>] " + "[,copyIndexes:<bool>] }" + "\nCopies a collection from one server to another. Do not use on a single server " + "as the destination " + "is placed at the same db.collection (namespace) as the source.\n"; } virtual bool errmsgRun(OperationContext* opCtx, diff --git a/src/mongo/db/commands/collection_to_capped.cpp b/src/mongo/db/commands/collection_to_capped.cpp index 8348dcd938a..14a3bf3f00e 100644 --- a/src/mongo/db/commands/collection_to_capped.cpp +++ b/src/mongo/db/commands/collection_to_capped.cpp @@ -58,8 +58,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return true; } - virtual void help(stringstream& help) const { - help << "{ cloneCollectionAsCapped:<fromName>, toCollection:<toName>, size:<sizeInBytes> }"; + std::string help() const override { + return "{ cloneCollectionAsCapped:<fromName>, toCollection:<toName>, size:<sizeInBytes> }"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, @@ -157,8 +157,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return true; } - virtual void help(stringstream& help) const { - help << "{ convertToCapped:<fromCollectionName>, size:<sizeInBytes> }"; + std::string help() const override { + return "{ convertToCapped:<fromCollectionName>, size:<sizeInBytes> }"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp index cb8ab25bd7a..e914d2f606d 100644 --- a/src/mongo/db/commands/compact.cpp +++ b/src/mongo/db/commands/compact.cpp @@ -74,15 +74,15 @@ public: actions.addAction(ActionType::compact); out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - virtual void help(stringstream& help) const { - help << "compact collection\n" - "warning: this operation locks the database and is slow. you can cancel with " - "killOp()\n" - "{ compact : <collection_name>, [force:<bool>], [validate:<bool>],\n" - " [paddingFactor:<num>], [paddingBytes:<num>] }\n" - " force - allows to run on a replica set primary\n" - " validate - check records are noncorrupt before adding to newly compacting " - "extents. slower but safer (defaults to true in this version)\n"; + std::string help() const override { + return "compact collection\n" + "warning: this operation locks the database and is slow. you can cancel with " + "killOp()\n" + "{ compact : <collection_name>, [force:<bool>], [validate:<bool>],\n" + " [paddingFactor:<num>], [paddingBytes:<num>] }\n" + " force - allows to run on a replica set primary\n" + " validate - check records are noncorrupt before adding to newly compacting " + "extents. slower but safer (defaults to true in this version)\n"; } CompactCmd() : ErrmsgCommandDeprecated("compact") {} diff --git a/src/mongo/db/commands/conn_pool_stats.cpp b/src/mongo/db/commands/conn_pool_stats.cpp index 6eda96aa727..298bbda74d4 100644 --- a/src/mongo/db/commands/conn_pool_stats.cpp +++ b/src/mongo/db/commands/conn_pool_stats.cpp @@ -49,8 +49,8 @@ class PoolStats final : public BasicCommand { public: PoolStats() : BasicCommand("connPoolStats") {} - void help(std::stringstream& help) const override { - help << "stats about connections between servers in a replica set or sharded cluster."; + std::string help() const override { + return "stats about connections between servers in a replica set or sharded cluster."; } bool slaveOk() const override { diff --git a/src/mongo/db/commands/conn_pool_sync.cpp b/src/mongo/db/commands/conn_pool_sync.cpp index c5831277334..44893d621e6 100644 --- a/src/mongo/db/commands/conn_pool_sync.cpp +++ b/src/mongo/db/commands/conn_pool_sync.cpp @@ -40,8 +40,8 @@ namespace mongo { class PoolFlushCmd : public BasicCommand { public: PoolFlushCmd() : BasicCommand("connPoolSync", "connpoolsync") {} - virtual void help(std::stringstream& help) const { - help << "internal"; + std::string help() const override { + return "internal"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; diff --git a/src/mongo/db/commands/connection_status.cpp b/src/mongo/db/commands/connection_status.cpp index 2a9c97f453f..14e6413014f 100644 --- a/src/mongo/db/commands/connection_status.cpp +++ b/src/mongo/db/commands/connection_status.cpp @@ -51,8 +51,8 @@ public: const BSONObj& cmdObj, std::vector<Privilege>* out) {} // No auth required - void help(stringstream& h) const { - h << "Returns connection-specific information such as logged-in users and their roles"; + std::string help() const override { + return "Returns connection-specific information such as logged-in users and their roles"; } bool run(OperationContext* opCtx, diff --git a/src/mongo/db/commands/copydb.cpp b/src/mongo/db/commands/copydb.cpp index 4f3c00fdab0..297ec8f1c10 100644 --- a/src/mongo/db/commands/copydb.cpp +++ b/src/mongo/db/commands/copydb.cpp @@ -109,10 +109,10 @@ public: return copydb::checkAuthForCopydbCommand(client, dbname, cmdObj); } - virtual void help(stringstream& help) const { - help << "copy a database from another host to this host\n"; - help << "usage: {copydb: 1, fromhost: <connection string>, fromdb: <db>, todb: <db>" - << "[, slaveOk: <bool>, username: <username>, nonce: <nonce>, key: <key>]}"; + std::string help() const override { + return "copy a database from another host to this host\n" + "usage: {copydb: 1, fromhost: <connection string>, fromdb: <db>, todb: <db>" + "[, slaveOk: <bool>, username: <username>, nonce: <nonce>, key: <key>]}"; } virtual bool errmsgRun(OperationContext* opCtx, diff --git a/src/mongo/db/commands/copydb_start_commands.cpp b/src/mongo/db/commands/copydb_start_commands.cpp index 3d1cd9786d2..59c21a4fcd2 100644 --- a/src/mongo/db/commands/copydb_start_commands.cpp +++ b/src/mongo/db/commands/copydb_start_commands.cpp @@ -94,9 +94,9 @@ public: return Status::OK(); } - virtual void help(stringstream& help) const { - help << "Initialize a SASL auth session for subsequent copy db request " - "from secure server\n"; + std::string help() const override { + return "Initialize a SASL auth session for subsequent copy db request " + "from secure server\n"; } virtual bool errmsgRun(OperationContext* opCtx, diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp index 68e99247586..639d842e1db 100644 --- a/src/mongo/db/commands/count_cmd.cpp +++ b/src/mongo/db/commands/count_cmd.cpp @@ -90,8 +90,8 @@ public: return ReadWriteType::kRead; } - virtual void help(stringstream& help) const { - help << "count objects in collection"; + std::string help() const override { + return "count objects in collection"; } Status checkAuthForOperation(OperationContext* opCtx, diff --git a/src/mongo/db/commands/cpuload.cpp b/src/mongo/db/commands/cpuload.cpp index 51192715b1a..be297b83ed6 100644 --- a/src/mongo/db/commands/cpuload.cpp +++ b/src/mongo/db/commands/cpuload.cpp @@ -48,12 +48,12 @@ public: virtual bool isWriteCommandForConfigServer() const { return false; } - virtual void help(stringstream& help) const { - help << "internal. for testing only."; - help << "{ cpuload : 1, cpuFactor : 1 } Runs a straight CPU load. Length of execution "; - help << "scaled by cpuFactor. Puts no additional load on the server beyond the cpu use."; - help << "Useful for testing the stability of the performance of the underlying system,"; - help << "by running the command repeatedly and observing the variation in execution time."; + std::string help() const override { + return "internal. for testing only." + "{ cpuload : 1, cpuFactor : 1 } Runs a straight CPU load. Length of execution " + "scaled by cpuFactor. Puts no additional load on the server beyond the cpu use." + "Useful for testing the stability of the performance of the underlying system," + "by running the command repeatedly and observing the variation in execution time."; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/dbcheck.cpp b/src/mongo/db/commands/dbcheck.cpp index 22ab02ceb32..15b6e6cd516 100644 --- a/src/mongo/db/commands/dbcheck.cpp +++ b/src/mongo/db/commands/dbcheck.cpp @@ -501,16 +501,16 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "Validate replica set consistency.\n" - << "Invoke with { dbCheck: <collection name/uuid>,\n" - << " minKey: <first key, exclusive>,\n" - << " maxKey: <last key, inclusive>,\n" - << " maxCount: <max number of docs>,\n" - << " maxSize: <max size of docs>,\n" - << " maxCountPerSecond: <max rate in docs/sec> } " - << "to check a collection.\n" - << "Invoke with {dbCheck: 1} to check all collections in the database."; + std::string help() const override { + return "Validate replica set consistency.\n" + "Invoke with { dbCheck: <collection name/uuid>,\n" + " minKey: <first key, exclusive>,\n" + " maxKey: <last key, inclusive>,\n" + " maxCount: <max number of docs>,\n" + " maxSize: <max size of docs>,\n" + " maxCountPerSecond: <max rate in docs/sec> } " + "to check a collection.\n" + "Invoke with {dbCheck: 1} to check all collections in the database."; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index 8e63f8f2137..b46512cd7e2 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -109,13 +109,13 @@ using std::unique_ptr; class CmdShutdownMongoD : public CmdShutdown { public: - virtual void help(stringstream& help) const { - help << "shutdown the database. must be ran against admin db and " - << "either (1) ran from localhost or (2) authenticated. If " - << "this is a primary in a replica set and there is no member " - << "within 10 seconds of its optime, it will not shutdown " - << "without force : true. You can also specify timeoutSecs : " - << "N to wait N seconds for other members to catch up."; + std::string help() const override { + return "shutdown the database. must be ran against admin db and " + "either (1) ran from localhost or (2) authenticated. If " + "this is a primary in a replica set and there is no member " + "within 10 seconds of its optime, it will not shutdown " + "without force : true. You can also specify timeoutSecs : " + "N to wait N seconds for other members to catch up."; } virtual bool run(OperationContext* opCtx, @@ -144,8 +144,8 @@ public: class CmdDropDatabase : public BasicCommand { public: - virtual void help(stringstream& help) const { - help << "drop (delete) this database"; + std::string help() const override { + return "drop (delete) this database"; } virtual bool slaveOk() const { return false; @@ -216,8 +216,8 @@ public: virtual bool maintenanceMode() const { return true; } - virtual void help(stringstream& help) const { - help << "repair database. also compacts. note: slow."; + std::string help() const override { + return "repair database. also compacts. note: slow."; } @@ -299,12 +299,12 @@ public: return true; } - virtual void help(stringstream& help) const { - help << "enable or disable performance profiling\n"; - help << "{ profile : <n> }\n"; - help << "0=off 1=log slow ops 2=log all\n"; - help << "-1 to get current values\n"; - help << "http://docs.mongodb.org/manual/reference/command/profile/#dbcmd.profile"; + std::string help() const override { + return "enable or disable performance profiling\n" + "{ profile : <n> }\n" + "0=off 1=log slow ops 2=log all\n" + "-1 to get current values\n" + "http://docs.mongodb.org/manual/reference/command/profile/#dbcmd.profile"; } @@ -409,8 +409,8 @@ public: actions.addAction(ActionType::dropCollection); out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - virtual void help(stringstream& help) const { - help << "drop a collection\n{drop : <collectionName>}"; + std::string help() const override { + return "drop a collection\n{drop : <collectionName>}"; } @@ -464,9 +464,9 @@ public: return true; } - virtual void help(stringstream& help) const { - help << "create a collection explicitly\n" - "{ create: <ns>[, capped: <bool>, size: <collSizeInBytes>, max: <nDocs>] }"; + std::string help() const override { + return "create a collection explicitly\n" + "{ create: <ns>[, capped: <bool>, size: <collSizeInBytes>, max: <nDocs>] }"; } virtual Status checkAuthForCommand(Client* client, const std::string& dbname, @@ -574,8 +574,8 @@ public: return true; } - virtual void help(stringstream& help) const { - help << " example: { filemd5 : ObjectId(aaaaaaa) , root : \"fs\" }"; + std::string help() const override { + return " example: { filemd5 : ObjectId(aaaaaaa) , root : \"fs\" }"; } @@ -753,17 +753,17 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void help(stringstream& help) const { - help << "determine data size for a set of data in a certain range" - "\nexample: { dataSize:\"blog.posts\", keyPattern:{x:1}, min:{x:10}, max:{x:55} }" - "\nmin and max parameters are optional. They must either both be included or both " - "omitted" - "\nkeyPattern is an optional parameter indicating an index pattern that would be " - "useful" - "for iterating over the min/max bounds. If keyPattern is omitted, it is inferred " - "from " - "the structure of min. " - "\nnote: This command may take a while to run"; + std::string help() const override { + return "determine data size for a set of data in a certain range" + "\nexample: { dataSize:\"blog.posts\", keyPattern:{x:1}, min:{x:10}, max:{x:55} }" + "\nmin and max parameters are optional. They must either both be included or both " + "omitted" + "\nkeyPattern is an optional parameter indicating an index pattern that would be " + "useful" + "for iterating over the min/max bounds. If keyPattern is omitted, it is inferred " + "from " + "the structure of min. " + "\nnote: This command may take a while to run"; } virtual void addRequiredPrivileges(const std::string& dbname, @@ -903,9 +903,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void help(stringstream& help) const { - help - << "{ collStats:\"blog.posts\" , scale : 1 } scale divides sizes e.g. for KB use 1024\n" + std::string help() const override { + return "{ collStats:\"blog.posts\" , scale : 1 } scale divides sizes e.g. for KB use 1024\n" " avgObjSize - in bytes"; } @@ -951,11 +950,11 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return true; } - virtual void help(stringstream& help) const { - help << "Sets collection options.\n" - "Example: { collMod: 'foo', usePowerOf2Sizes:true }\n" - "Example: { collMod: 'foo', index: {keyPattern: {a: 1}, expireAfterSeconds: 600} " - "Example: { collMod: 'foo', index: {name: 'bar', expireAfterSeconds: 600} }\n"; + std::string help() const override { + return "Sets collection options.\n" + "Example: { collMod: 'foo', usePowerOf2Sizes:true }\n" + "Example: { collMod: 'foo', index: {keyPattern: {a: 1}, expireAfterSeconds: 600} " + "Example: { collMod: 'foo', index: {name: 'bar', expireAfterSeconds: 600} }\n"; } virtual Status checkAuthForCommand(Client* client, @@ -985,10 +984,10 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void help(stringstream& help) const { - help << "Get stats on a database. Not instantaneous. Slower for databases with large " - ".ns files.\n" - "Example: { dbStats:1, scale:1 }"; + std::string help() const override { + return "Get stats on a database. Not instantaneous. Slower for databases with large " + ".ns files.\n" + "Example: { dbStats:1, scale:1 }"; } virtual void addRequiredPrivileges(const std::string& dbname, @@ -1081,8 +1080,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void help(stringstream& help) const { - help << "{whatsmyuri:1}"; + std::string help() const override { + return "{whatsmyuri:1}"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp index 84fdb451376..b12a485d68e 100644 --- a/src/mongo/db/commands/distinct.cpp +++ b/src/mongo/db/commands/distinct.cpp @@ -109,8 +109,8 @@ public: out->push_back(Privilege(parseResourcePattern(dbname, cmdObj), actions)); } - virtual void help(stringstream& help) const { - help << "{ distinct : 'collection name' , key : 'a.b' , query : {} }"; + std::string help() const override { + return "{ distinct : 'collection name' , key : 'a.b' , query : {} }"; } virtual Status explain(OperationContext* opCtx, diff --git a/src/mongo/db/commands/do_txn_cmd.cpp b/src/mongo/db/commands/do_txn_cmd.cpp index f695470f034..3193b5ba30d 100644 --- a/src/mongo/db/commands/do_txn_cmd.cpp +++ b/src/mongo/db/commands/do_txn_cmd.cpp @@ -139,9 +139,9 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "internal (sharding)\n{ doTxn : [ ] , preCondition : [ { ns : ... , q : ... , " - "res : ... } ] }"; + std::string help() const override { + return "internal (sharding)\n{ doTxn : [ ] , preCondition : [ { ns : ... , q : ... , " + "res : ... } ] }"; } Status checkAuthForOperation(OperationContext* opCtx, diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp index d49ab60c73a..8f311a94295 100644 --- a/src/mongo/db/commands/drop_indexes.cpp +++ b/src/mongo/db/commands/drop_indexes.cpp @@ -72,8 +72,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return true; } - virtual void help(stringstream& help) const { - help << "drop indexes for a collection"; + std::string help() const override { + return "drop indexes for a collection"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, @@ -102,8 +102,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void help(stringstream& help) const { - help << "re-index a collection"; + std::string help() const override { + return "re-index a collection"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/end_sessions_command.cpp b/src/mongo/db/commands/end_sessions_command.cpp index 74fa70a0f66..39383f8e58d 100644 --- a/src/mongo/db/commands/end_sessions_command.cpp +++ b/src/mongo/db/commands/end_sessions_command.cpp @@ -53,8 +53,8 @@ public: bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - void help(std::stringstream& help) const override { - help << "end a set of logical sessions"; + std::string help() const override { + return "end a set of logical sessions"; } Status checkAuthForOperation(OperationContext* opCtx, const std::string& dbname, diff --git a/src/mongo/db/commands/eval.cpp b/src/mongo/db/commands/eval.cpp index 6a83aadfcc0..36153a54181 100644 --- a/src/mongo/db/commands/eval.cpp +++ b/src/mongo/db/commands/eval.cpp @@ -158,10 +158,10 @@ public: return false; } - virtual void help(stringstream& help) const { - help << "DEPRECATED\n" - << "Evaluate javascript at the server.\n" - << "http://dochub.mongodb.org/core/serversidecodeexecution"; + std::string help() const override { + return "DEPRECATED\n" + "Evaluate javascript at the server.\n" + "http://dochub.mongodb.org/core/serversidecodeexecution"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; diff --git a/src/mongo/db/commands/explain_cmd.cpp b/src/mongo/db/commands/explain_cmd.cpp index c89ca471c2d..08463e626df 100644 --- a/src/mongo/db/commands/explain_cmd.cpp +++ b/src/mongo/db/commands/explain_cmd.cpp @@ -78,8 +78,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "explain database reads and writes"; + std::string help() const override { + return "explain database reads and writes"; } std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const override { diff --git a/src/mongo/db/commands/fail_point_cmd.cpp b/src/mongo/db/commands/fail_point_cmd.cpp index c5fcda4b995..efb705a7bff 100644 --- a/src/mongo/db/commands/fail_point_cmd.cpp +++ b/src/mongo/db/commands/fail_point_cmd.cpp @@ -86,8 +86,8 @@ public: const BSONObj& cmdObj, std::vector<Privilege>* out) {} - virtual void help(stringstream& h) const { - h << "modifies the settings of a fail point"; + std::string help() const override { + return "modifies the settings of a fail point"; } bool errmsgRun(OperationContext* opCtx, diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index cf3bb5609c8..1e8193ce4c9 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -211,13 +211,13 @@ class CmdFindAndModify : public BasicCommand { public: CmdFindAndModify() : BasicCommand("findAndModify", "findandmodify") {} - void help(std::stringstream& help) const override { - help << "{ findAndModify: \"collection\", query: {processed:false}, update: {$set: " - "{processed:true}}, new: true}\n" - "{ findAndModify: \"collection\", query: {processed:false}, remove: true, sort: " - "{priority:-1}}\n" - "Either update or remove is required, all other fields have default values.\n" - "Output is in the \"value\" field\n"; + std::string help() const override { + return "{ findAndModify: \"collection\", query: {processed:false}, update: {$set: " + "{processed:true}}, new: true}\n" + "{ findAndModify: \"collection\", query: {processed:false}, remove: true, sort: " + "{priority:-1}}\n" + "Either update or remove is required, all other fields have default values.\n" + "Output is in the \"value\" field\n"; } bool slaveOk() const override { diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp index ccb97bd98a5..1ce3f931e5b 100644 --- a/src/mongo/db/commands/find_cmd.cpp +++ b/src/mongo/db/commands/find_cmd.cpp @@ -91,8 +91,8 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "query for documents"; + std::string help() const override { + return "query for documents"; } LogicalOp getLogicalOp() const override { diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp index fe5945e4589..eb2b2d375c7 100644 --- a/src/mongo/db/commands/fsync.cpp +++ b/src/mongo/db/commands/fsync.cpp @@ -107,8 +107,8 @@ public: virtual bool adminOnly() const { return true; } - virtual void help(stringstream& h) const { - h << url(); + std::string help() const override { + return url(); } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp index c80e18e03bb..d5bd5b0da1e 100644 --- a/src/mongo/db/commands/generic.cpp +++ b/src/mongo/db/commands/generic.cpp @@ -85,9 +85,9 @@ public: virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector<Privilege>* out) {} // No auth required - virtual void help(stringstream& help) const { - help << "get version #, etc.\n"; - help << "{ buildinfo:1 }"; + std::string help() const override { + return "get version #, etc.\n" + "{ buildinfo:1 }"; } bool run(OperationContext* opCtx, @@ -107,9 +107,9 @@ public: virtual bool slaveOk() const { return true; } - virtual void help(stringstream& help) const { - help << "a way to check that the server is alive. responds immediately even if server is " - "in a db lock."; + std::string help() const override { + return "a way to check that the server is alive. responds immediately even if server is " + "in a db lock."; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; @@ -135,8 +135,8 @@ public: class FeaturesCmd : public BasicCommand { public: FeaturesCmd() : BasicCommand("features") {} - void help(stringstream& h) const { - h << "return build level feature settings"; + std::string help() const override { + return "return build level feature settings"; } virtual bool slaveOk() const { return true; @@ -178,8 +178,8 @@ public: return false; } - virtual void help(stringstream& help) const { - help << "returns information about the daemon's host"; + std::string help() const override { + return "returns information about the daemon's host"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, @@ -248,8 +248,8 @@ public: class ListCommandsCmd : public BasicCommand { public: - virtual void help(stringstream& help) const { - help << "get a list of all db commands"; + std::string help() const override { + return "get a list of all db commands"; } ListCommandsCmd() : BasicCommand("listCommands") {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { @@ -282,12 +282,7 @@ public: BSONObjBuilder b(result.subobjStart("commands")); for (const auto& c : commands) { BSONObjBuilder temp(b.subobjStart(c->getName())); - - { - stringstream help; - c->help(help); - temp.append("help", help.str()); - } + temp.append("help", c->help()); temp.append("slaveOk", c->slaveOk()); temp.append("adminOnly", c->adminOnly()); // optionally indicates that the command can be forced to run on a slave/secondary @@ -305,8 +300,8 @@ public: /* for testing purposes only */ class CmdForceError : public BasicCommand { public: - virtual void help(stringstream& help) const { - help << "for testing purposes only. forces a user assertion exception"; + std::string help() const override { + return "for testing purposes only. forces a user assertion exception"; } virtual bool slaveOk() const { return true; @@ -347,8 +342,8 @@ public: actions.addAction(ActionType::getLog); out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - virtual void help(stringstream& help) const { - help << "{ getLog : '*' } OR { getLog : 'global' }"; + std::string help() const override { + return "{ getLog : '*' } OR { getLog : 'global' }"; } virtual bool errmsgRun(OperationContext* opCtx, @@ -418,8 +413,8 @@ public: // enabled at the command line. return Status::OK(); } - virtual void help(stringstream& help) const { - help << "{ clearLog : 'global' }"; + std::string help() const override { + return "{ clearLog : 'global' }"; } virtual bool run(OperationContext* opCtx, @@ -454,8 +449,8 @@ MONGO_INITIALIZER(RegisterClearLogCmd)(InitializerContext* context) { class CmdGetCmdLineOpts : public BasicCommand { public: CmdGetCmdLineOpts() : BasicCommand("getCmdLineOpts") {} - void help(stringstream& h) const { - h << "get argv"; + std::string help() const override { + return "get argv"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; diff --git a/src/mongo/db/commands/geo_near_cmd.cpp b/src/mongo/db/commands/geo_near_cmd.cpp index 4eb9ac3075b..ac1d839100b 100644 --- a/src/mongo/db/commands/geo_near_cmd.cpp +++ b/src/mongo/db/commands/geo_near_cmd.cpp @@ -94,8 +94,8 @@ public: return FindCommon::kInitReplyBufferSize; } - void help(stringstream& h) const { - h << "http://dochub.mongodb.org/core/geo#GeospatialIndexing-geoNearCommand"; + std::string help() const override { + return "http://dochub.mongodb.org/core/geo#GeospatialIndexing-geoNearCommand"; } virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/db/commands/get_last_error.cpp b/src/mongo/db/commands/get_last_error.cpp index 567ea05a6e6..3d2d6d414c1 100644 --- a/src/mongo/db/commands/get_last_error.cpp +++ b/src/mongo/db/commands/get_last_error.cpp @@ -71,8 +71,8 @@ public: return false; } - virtual void help(stringstream& help) const { - help << "reset error state (used with getpreverror)"; + std::string help() const override { + return "reset error state (used with getpreverror)"; } CmdResetError() : BasicCommand("resetError", "reseterror") {} bool run(OperationContext* opCtx, @@ -101,15 +101,15 @@ public: return false; } - virtual void help(stringstream& help) const { - help << "return error status of the last operation on this connection\n" - << "options:\n" - << " { fsync:true } - fsync before returning, or wait for journal commit if running " - "with --journal\n" - << " { j:true } - wait for journal commit if running with --journal\n" - << " { w:n } - await replication to n servers (including self) before returning\n" - << " { w:'majority' } - await replication to majority of set\n" - << " { wtimeout:m} - timeout for w in m milliseconds"; + std::string help() const override { + return "return error status of the last operation on this connection\n" + "options:\n" + " { fsync:true } - fsync before returning, or wait for journal commit if running " + "with --journal\n" + " { j:true } - wait for journal commit if running with --journal\n" + " { w:n } - await replication to n servers (including self) before returning\n" + " { w:'majority' } - await replication to majority of set\n" + " { wtimeout:m} - timeout for w in m milliseconds"; } bool errmsgRun(OperationContext* opCtx, @@ -310,8 +310,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void help(stringstream& help) const { - help << "check for errors since last reseterror commandcal"; + std::string help() const override { + return "check for errors since last reseterror commandcal"; } virtual bool slaveOk() const { return true; diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 8e40999ca36..594a2886d08 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -112,8 +112,8 @@ public: return ReadWriteType::kRead; } - void help(std::stringstream& help) const override { - help << "retrieve more results from an existing cursor"; + std::string help() const override { + return "retrieve more results from an existing cursor"; } LogicalOp getLogicalOp() const override { diff --git a/src/mongo/db/commands/group_cmd.cpp b/src/mongo/db/commands/group_cmd.cpp index 4025fb138bf..85b93ec071a 100644 --- a/src/mongo/db/commands/group_cmd.cpp +++ b/src/mongo/db/commands/group_cmd.cpp @@ -93,8 +93,8 @@ private: return FindCommon::kInitReplyBufferSize; } - virtual void help(std::stringstream& help) const { - help << "http://dochub.mongodb.org/core/aggregation"; + std::string help() const override { + return "http://dochub.mongodb.org/core/aggregation"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/hashcmd.cpp b/src/mongo/db/commands/hashcmd.cpp index 0b4ebdba718..f65fda66d84 100644 --- a/src/mongo/db/commands/hashcmd.cpp +++ b/src/mongo/db/commands/hashcmd.cpp @@ -63,8 +63,8 @@ public: virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector<Privilege>* out) {} - virtual void help(stringstream& help) const { - help << "returns the hash of the first BSONElement val in a BSONObj"; + std::string help() const override { + return "returns the hash of the first BSONElement val in a BSONObj"; } /* CmdObj has the form {"hash" : <thingToHash>} diff --git a/src/mongo/db/commands/index_filter_commands.cpp b/src/mongo/db/commands/index_filter_commands.cpp index d8187c00861..1eaeadcd656 100644 --- a/src/mongo/db/commands/index_filter_commands.cpp +++ b/src/mongo/db/commands/index_filter_commands.cpp @@ -137,8 +137,8 @@ bool IndexFilterCommand::slaveOverrideOk() const { return true; } -void IndexFilterCommand::help(stringstream& ss) const { - ss << helpText; +std::string IndexFilterCommand::help() const { + return helpText; } Status IndexFilterCommand::checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/index_filter_commands.h b/src/mongo/db/commands/index_filter_commands.h index 6a313e1f93c..aaa785c0d6b 100644 --- a/src/mongo/db/commands/index_filter_commands.h +++ b/src/mongo/db/commands/index_filter_commands.h @@ -74,7 +74,7 @@ public: virtual bool slaveOverrideOk() const; - virtual void help(std::stringstream& ss) const; + std::string help() const override; /** * One action type defined for index filter commands: diff --git a/src/mongo/db/commands/isself.cpp b/src/mongo/db/commands/isself.cpp index ed7605f14b7..841dfde9e54 100644 --- a/src/mongo/db/commands/isself.cpp +++ b/src/mongo/db/commands/isself.cpp @@ -48,8 +48,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void help(stringstream& help) const { - help << "{ _isSelf : 1 } INTERNAL ONLY"; + std::string help() const override { + return "{ _isSelf : 1 } INTERNAL ONLY"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp b/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp index 9388e593be5..708cb67d34b 100644 --- a/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp +++ b/src/mongo/db/commands/kill_all_sessions_by_pattern_command.cpp @@ -66,8 +66,8 @@ public: bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - void help(std::stringstream& help) const override { - help << "kill logical sessions by pattern"; + std::string help() const override { + return "kill logical sessions by pattern"; } Status checkAuthForOperation(OperationContext* opCtx, const std::string& dbname, diff --git a/src/mongo/db/commands/kill_all_sessions_command.cpp b/src/mongo/db/commands/kill_all_sessions_command.cpp index 70137a4ad28..86f0a629249 100644 --- a/src/mongo/db/commands/kill_all_sessions_command.cpp +++ b/src/mongo/db/commands/kill_all_sessions_command.cpp @@ -66,8 +66,8 @@ public: bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - void help(std::stringstream& help) const override { - help << "kill all logical sessions, for a user, and their operations"; + std::string help() const override { + return "kill all logical sessions, for a user, and their operations"; } Status checkAuthForOperation(OperationContext* opCtx, const std::string& dbname, diff --git a/src/mongo/db/commands/kill_sessions_command.cpp b/src/mongo/db/commands/kill_sessions_command.cpp index f371dc5b80d..0be33339f25 100644 --- a/src/mongo/db/commands/kill_sessions_command.cpp +++ b/src/mongo/db/commands/kill_sessions_command.cpp @@ -93,8 +93,8 @@ public: bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - void help(std::stringstream& help) const override { - help << "kill a logical session and its operations"; + std::string help() const override { + return "kill a logical session and its operations"; } // Any user can kill their own sessions diff --git a/src/mongo/db/commands/killcursors_common.h b/src/mongo/db/commands/killcursors_common.h index e34bd5098da..6991a4a0da7 100644 --- a/src/mongo/db/commands/killcursors_common.h +++ b/src/mongo/db/commands/killcursors_common.h @@ -57,8 +57,8 @@ public: return false; } - void help(std::stringstream& help) const final { - help << "kill a list of cursor ids"; + std::string help() const final { + return "kill a list of cursor ids"; } bool shouldAffectCommandCounter() const final { diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp index d596a1644fc..b21c0f959a1 100644 --- a/src/mongo/db/commands/list_collections.cpp +++ b/src/mongo/db/commands/list_collections.cpp @@ -210,8 +210,8 @@ public: return false; } - virtual void help(stringstream& help) const { - help << "list collections for this db"; + std::string help() const override { + return "list collections for this db"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/list_databases.cpp b/src/mongo/db/commands/list_databases.cpp index 0012e114c90..f91cb10f680 100644 --- a/src/mongo/db/commands/list_databases.cpp +++ b/src/mongo/db/commands/list_databases.cpp @@ -69,9 +69,9 @@ public: bool supportsWriteConcern(const BSONObj& cmd) const final { return false; } - void help(stringstream& help) const final { - help << "{ listDatabases:1, [filter: <filterObject>] [, nameOnly: true ] }\n" - "list databases on this server"; + std::string help() const final { + return "{ listDatabases:1, [filter: <filterObject>] [, nameOnly: true ] }\n" + "list databases on this server"; } /* listDatabases is always authorized, diff --git a/src/mongo/db/commands/list_indexes.cpp b/src/mongo/db/commands/list_indexes.cpp index 10e4be8af33..5c23ea9f1c6 100644 --- a/src/mongo/db/commands/list_indexes.cpp +++ b/src/mongo/db/commands/list_indexes.cpp @@ -89,8 +89,8 @@ public: return false; } - virtual void help(stringstream& help) const { - help << "list indexes for a collection"; + std::string help() const override { + return "list indexes for a collection"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/lock_info.cpp b/src/mongo/db/commands/lock_info.cpp index 7273a5ff238..6bd6aeb3258 100644 --- a/src/mongo/db/commands/lock_info.cpp +++ b/src/mongo/db/commands/lock_info.cpp @@ -65,8 +65,8 @@ public: return false; } - virtual void help(stringstream& help) const { - help << "show all lock info on the server"; + std::string help() const override { + return "show all lock info on the server"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 7431474ee6a..ef9043fd78a 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -1364,10 +1364,10 @@ public: return FindCommon::kInitReplyBufferSize; } - virtual void help(stringstream& help) const { - help << "Run a map/reduce operation on the server.\n"; - help << "Note this is used for aggregation, not querying, in MongoDB.\n"; - help << "http://dochub.mongodb.org/core/mapreduce"; + std::string help() const override { + return "Run a map/reduce operation on the server.\n" + "Note this is used for aggregation, not querying, in MongoDB.\n" + "http://dochub.mongodb.org/core/mapreduce"; } @@ -1685,8 +1685,8 @@ public: */ class MapReduceFinishCommand : public BasicCommand { public: - void help(stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } MapReduceFinishCommand() : BasicCommand("mapreduce.shardedfinish") {} virtual bool slaveOk() const { diff --git a/src/mongo/db/commands/oplog_note.cpp b/src/mongo/db/commands/oplog_note.cpp index 6ebbc1e28bd..9b26b979ba6 100644 --- a/src/mongo/db/commands/oplog_note.cpp +++ b/src/mongo/db/commands/oplog_note.cpp @@ -99,8 +99,8 @@ public: return true; } - virtual void help(stringstream& help) const { - help << "Adds a no-op entry to the oplog"; + std::string help() const override { + return "Adds a no-op entry to the oplog"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp index 224b0cb0fcc..7e03b90985b 100644 --- a/src/mongo/db/commands/parameters.cpp +++ b/src/mongo/db/commands/parameters.cpp @@ -54,11 +54,12 @@ using std::stringstream; namespace mongo { namespace { -void appendParameterNames(stringstream& help) { - help << "supported:\n"; - const ServerParameter::Map& m = ServerParameterSet::getGlobal()->getMap(); - for (ServerParameter::Map::const_iterator i = m.begin(); i != m.end(); ++i) { - help << " " << i->first << "\n"; +void appendParameterNames(std::string* help) { + *help += "supported:\n"; + for (const auto& kv : ServerParameterSet::getGlobal()->getMap()) { + *help += " "; + *help += kv.first; + *help += '\n'; } } } @@ -82,11 +83,13 @@ public: actions.addAction(ActionType::getParameter); out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - virtual void help(stringstream& help) const { - help << "get administrative option(s)\nexample:\n"; - help << "{ getParameter:1, notablescan:1 }\n"; - appendParameterNames(help); - help << "{ getParameter:'*' } to get everything\n"; + std::string help() const override { + std::string h = + "get administrative option(s)\nexample:\n" + "{ getParameter:1, notablescan:1 }\n"; + appendParameterNames(&h); + h += "{ getParameter:'*' } to get everything\n"; + return h; } bool errmsgRun(OperationContext* opCtx, const string& dbname, @@ -131,10 +134,12 @@ public: actions.addAction(ActionType::setParameter); out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - virtual void help(stringstream& help) const { - help << "set administrative option(s)\n"; - help << "{ setParameter:1, <param>:<value> }\n"; - appendParameterNames(help); + std::string help() const override { + std::string h = + "set administrative option(s)\n" + "{ setParameter:1, <param>:<value> }\n"; + appendParameterNames(&h); + return h; } bool errmsgRun(OperationContext* opCtx, const string& dbname, diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp index 3cc4b4d1e8e..8ec12102c35 100644 --- a/src/mongo/db/commands/pipeline_command.cpp +++ b/src/mongo/db/commands/pipeline_command.cpp @@ -48,9 +48,9 @@ class PipelineCommand : public BasicCommand { public: PipelineCommand() : BasicCommand("aggregate") {} - void help(std::stringstream& help) const override { - help << "Runs the aggregation command. See http://dochub.mongodb.org/core/aggregation for " - "more details."; + std::string help() const override { + return "Runs the aggregation command. See http://dochub.mongodb.org/core/aggregation for " + "more details."; } bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/commands/plan_cache_commands.cpp b/src/mongo/db/commands/plan_cache_commands.cpp index fc8ef25f39e..0cd3593f5c1 100644 --- a/src/mongo/db/commands/plan_cache_commands.cpp +++ b/src/mongo/db/commands/plan_cache_commands.cpp @@ -132,8 +132,8 @@ bool PlanCacheCommand::slaveOverrideOk() const { return true; } -void PlanCacheCommand::help(stringstream& ss) const { - ss << helpText; +std::string PlanCacheCommand::help() const { + return helpText; } Status PlanCacheCommand::checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/plan_cache_commands.h b/src/mongo/db/commands/plan_cache_commands.h index da3400ca863..0b0a680b2da 100644 --- a/src/mongo/db/commands/plan_cache_commands.h +++ b/src/mongo/db/commands/plan_cache_commands.h @@ -68,7 +68,7 @@ public: virtual bool slaveOverrideOk() const; - virtual void help(std::stringstream& ss) const; + std::string help() const override; /** * Two action types defined for plan cache commands: diff --git a/src/mongo/db/commands/reap_logical_session_cache_now.cpp b/src/mongo/db/commands/reap_logical_session_cache_now.cpp index 50abcd781ad..879952791fc 100644 --- a/src/mongo/db/commands/reap_logical_session_cache_now.cpp +++ b/src/mongo/db/commands/reap_logical_session_cache_now.cpp @@ -56,8 +56,8 @@ public: return false; } - void help(std::stringstream& help) const override { - help << "force the logical session cache to reap. Test command only."; + std::string help() const override { + return "force the logical session cache to reap. Test command only."; } // No auth needed because it only works when enabled via command line. diff --git a/src/mongo/db/commands/refresh_logical_session_cache_now.cpp b/src/mongo/db/commands/refresh_logical_session_cache_now.cpp index b98d6a48815..5dcbe213eaa 100644 --- a/src/mongo/db/commands/refresh_logical_session_cache_now.cpp +++ b/src/mongo/db/commands/refresh_logical_session_cache_now.cpp @@ -57,8 +57,8 @@ public: return false; } - void help(std::stringstream& help) const override { - help << "force the logical session cache to refresh. Test command only."; + std::string help() const override { + return "force the logical session cache to refresh. Test command only."; } // No auth needed because it only works when enabled via command line. diff --git a/src/mongo/db/commands/refresh_sessions_command.cpp b/src/mongo/db/commands/refresh_sessions_command.cpp index 894b3d9d1b6..4db76567261 100644 --- a/src/mongo/db/commands/refresh_sessions_command.cpp +++ b/src/mongo/db/commands/refresh_sessions_command.cpp @@ -55,8 +55,8 @@ public: bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - void help(std::stringstream& help) const override { - help << "renew a set of logical sessions"; + std::string help() const override { + return "renew a set of logical sessions"; } Status checkAuthForOperation(OperationContext* opCtx, const std::string& dbname, diff --git a/src/mongo/db/commands/refresh_sessions_command_internal.cpp b/src/mongo/db/commands/refresh_sessions_command_internal.cpp index 74e36cf5462..1cfbf7deeb0 100644 --- a/src/mongo/db/commands/refresh_sessions_command_internal.cpp +++ b/src/mongo/db/commands/refresh_sessions_command_internal.cpp @@ -55,8 +55,8 @@ public: bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - void help(std::stringstream& help) const override { - help << "renew a set of logical sessions"; + std::string help() const override { + return "renew a set of logical sessions"; } Status checkAuthForOperation(OperationContext* opCtx, const std::string& dbname, diff --git a/src/mongo/db/commands/rename_collection_cmd.cpp b/src/mongo/db/commands/rename_collection_cmd.cpp index aac288179a2..144ecbf847e 100644 --- a/src/mongo/db/commands/rename_collection_cmd.cpp +++ b/src/mongo/db/commands/rename_collection_cmd.cpp @@ -73,8 +73,8 @@ public: const BSONObj& cmdObj) { return rename_collection::checkAuthForRenameCollectionCommand(client, dbname, cmdObj); } - virtual void help(stringstream& help) const { - help << " example: { renameCollection: foo.a, to: bar.b }"; + std::string help() const override { + return " example: { renameCollection: foo.a, to: bar.b }"; } static void dropCollection(OperationContext* opCtx, Database* db, StringData collName) { diff --git a/src/mongo/db/commands/resize_oplog.cpp b/src/mongo/db/commands/resize_oplog.cpp index 7c85812ba14..4373c9c9dd5 100644 --- a/src/mongo/db/commands/resize_oplog.cpp +++ b/src/mongo/db/commands/resize_oplog.cpp @@ -66,8 +66,8 @@ public: return false; } - virtual void help(stringstream& help) const { - help << "resize oplog size in MB"; + std::string help() const override { + return "resize oplog size in MB"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/server_status.cpp b/src/mongo/db/commands/server_status.cpp index b3946ccbd12..a4b63e778f2 100644 --- a/src/mongo/db/commands/server_status.cpp +++ b/src/mongo/db/commands/server_status.cpp @@ -78,8 +78,8 @@ public: virtual bool allowsAfterClusterTime(const BSONObj& cmdObj) const override { return false; } - virtual void help(stringstream& help) const { - help << "returns lots of administrative server statistics"; + std::string help() const override { + return "returns lots of administrative server statistics"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp index 683bec4179c..31e28b6a5b5 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -81,14 +81,16 @@ public: return true; } - virtual void help(std::stringstream& help) const { - help << "Set the API version exposed by this node. If set to \"" - << FeatureCompatibilityVersionCommandParser::kVersion34 - << "\", then 3.6 features are disabled. If \"" - << FeatureCompatibilityVersionCommandParser::kVersion36 - << "\", then 3.6 features are enabled, and all nodes in the cluster must be version " - "3.6. See " - << feature_compatibility_version::kDochubLink << "."; + std::string help() const override { + std::stringstream h; + h << "Set the API version exposed by this node. If set to \"" + << FeatureCompatibilityVersionCommandParser::kVersion34 + << "\", then 3.6 features are disabled. If \"" + << FeatureCompatibilityVersionCommandParser::kVersion36 + << "\", then 3.6 features are enabled, and all nodes in the cluster must be version " + "3.6. See " + << feature_compatibility_version::kDochubLink << "."; + return h.str(); } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/snapshot_management.cpp b/src/mongo/db/commands/snapshot_management.cpp index 33b5b9f0f85..3661447d224 100644 --- a/src/mongo/db/commands/snapshot_management.cpp +++ b/src/mongo/db/commands/snapshot_management.cpp @@ -61,8 +61,8 @@ public: return Status::OK(); } - virtual void help(std::stringstream& h) const { - h << "Creates a new named snapshot"; + std::string help() const override { + return "Creates a new named snapshot"; } bool run(OperationContext* opCtx, @@ -109,8 +109,8 @@ public: return Status::OK(); } - virtual void help(std::stringstream& h) const { - h << "Sets the snapshot for {readConcern: {level: 'majority'}}"; + std::string help() const override { + return "Sets the snapshot for {readConcern: {level: 'majority'}}"; } bool run(OperationContext* opCtx, diff --git a/src/mongo/db/commands/start_session_command.cpp b/src/mongo/db/commands/start_session_command.cpp index 47e4e7726c3..b621ca02237 100644 --- a/src/mongo/db/commands/start_session_command.cpp +++ b/src/mongo/db/commands/start_session_command.cpp @@ -60,8 +60,8 @@ public: bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - void help(std::stringstream& help) const override { - help << "start a logical session"; + std::string help() const override { + return "start a logical session"; } Status checkAuthForOperation(OperationContext* opCtx, const std::string& dbname, diff --git a/src/mongo/db/commands/test_commands.cpp b/src/mongo/db/commands/test_commands.cpp index 2dd96eeee8c..1615117783e 100644 --- a/src/mongo/db/commands/test_commands.cpp +++ b/src/mongo/db/commands/test_commands.cpp @@ -72,8 +72,8 @@ public: virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, std::vector<Privilege>* out) {} - virtual void help(stringstream& help) const { - help << "internal. for testing only."; + std::string help() const override { + return "internal. for testing only."; } virtual bool errmsgRun(OperationContext* opCtx, const string& dbname, @@ -122,15 +122,15 @@ public: return true; } - virtual void help(stringstream& help) const { - help << "internal testing command. Run a no-op command for an arbitrary amount of time. "; - help << "If neither 'secs' nor 'millis' is set, command will sleep for 10 seconds. "; - help << "If both are set, command will sleep for the sum of 'secs' and 'millis.'\n"; - help << " w:<bool> (deprecated: use 'lock' instead) if true, takes a write lock.\n"; - help << " lock: r, w, none. If r or w, db will block under a lock. Defaults to r."; - help << " 'lock' and 'w' may not both be set.\n"; - help << " secs:<seconds> Amount of time to sleep, in seconds.\n"; - help << " millis:<milliseconds> Amount of time to sleep, in ms.\n"; + std::string help() const override { + return "internal testing command. Run a no-op command for an arbitrary amount of time. " + "If neither 'secs' nor 'millis' is set, command will sleep for 10 seconds. " + "If both are set, command will sleep for the sum of 'secs' and 'millis.'\n" + " w:<bool> (deprecated: use 'lock' instead) if true, takes a write lock.\n" + " lock: r, w, none. If r or w, db will block under a lock. Defaults to r." + " 'lock' and 'w' may not both be set.\n" + " secs:<seconds> Amount of time to sleep, in seconds.\n" + " millis:<milliseconds> Amount of time to sleep, in ms.\n"; } // No auth needed because it only works when enabled via command line. diff --git a/src/mongo/db/commands/top_command.cpp b/src/mongo/db/commands/top_command.cpp index 678bb86b320..241c44e5702 100644 --- a/src/mongo/db/commands/top_command.cpp +++ b/src/mongo/db/commands/top_command.cpp @@ -55,8 +55,8 @@ public: virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; } - virtual void help(std::stringstream& help) const { - help << "usage by collection, in micros "; + std::string help() const override { + return "usage by collection, in micros "; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/touch.cpp b/src/mongo/db/commands/touch.cpp index 2d430378475..d9c2651f34d 100644 --- a/src/mongo/db/commands/touch.cpp +++ b/src/mongo/db/commands/touch.cpp @@ -67,11 +67,11 @@ public: virtual bool maintenanceMode() const { return true; } - virtual void help(stringstream& help) const { - help << "touch collection\n" - "Page in all pages of memory containing every extent for the given collection\n" - "{ touch : <collection_name>, [data : true] , [index : true] }\n" - " at least one of data or index must be true; default is both are false\n"; + std::string help() const override { + return "touch collection\n" + "Page in all pages of memory containing every extent for the given collection\n" + "{ touch : <collection_name>, [data : true] , [index : true] }\n" + " at least one of data or index must be true; default is both are false\n"; } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp index f2d3bcbeed2..9ccf077f479 100644 --- a/src/mongo/db/commands/user_management_commands.cpp +++ b/src/mongo/db/commands/user_management_commands.cpp @@ -619,8 +619,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Adds a user to the system" << endl; + std::string help() const override { + return "Adds a user to the system"; } virtual Status checkAuthForCommand(Client* client, @@ -766,8 +766,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Used to update a user, for example to change its password" << endl; + std::string help() const override { + return "Used to update a user, for example to change its password"; } virtual Status checkAuthForCommand(Client* client, @@ -900,8 +900,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Drops a single user." << endl; + std::string help() const override { + return "Drops a single user."; } virtual Status checkAuthForCommand(Client* client, @@ -967,8 +967,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Drops all users for a single database." << endl; + std::string help() const override { + return "Drops all users for a single database."; } virtual Status checkAuthForCommand(Client* client, @@ -1023,8 +1023,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Grants roles to a user." << endl; + std::string help() const override { + return "Grants roles to a user."; } virtual Status checkAuthForCommand(Client* client, @@ -1095,8 +1095,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Revokes roles from a user." << endl; + std::string help() const override { + return "Revokes roles from a user."; } virtual Status checkAuthForCommand(Client* client, @@ -1171,8 +1171,8 @@ public: CmdUsersInfo() : BasicCommand("usersInfo") {} - virtual void help(stringstream& ss) const { - ss << "Returns information about users." << endl; + std::string help() const override { + return "Returns information about users."; } virtual Status checkAuthForCommand(Client* client, @@ -1293,8 +1293,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Adds a role to the system" << endl; + std::string help() const override { + return "Adds a role to the system"; } virtual Status checkAuthForCommand(Client* client, @@ -1414,8 +1414,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Used to update a role" << endl; + std::string help() const override { + return "Used to update a role"; } virtual Status checkAuthForCommand(Client* client, @@ -1531,8 +1531,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Grants privileges to a role" << endl; + std::string help() const override { + return "Grants privileges to a role"; } virtual Status checkAuthForCommand(Client* client, @@ -1641,8 +1641,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Revokes privileges from a role" << endl; + std::string help() const override { + return "Revokes privileges from a role"; } virtual Status checkAuthForCommand(Client* client, @@ -1753,8 +1753,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Grants roles to another role." << endl; + std::string help() const override { + return "Grants roles to another role."; } virtual Status checkAuthForCommand(Client* client, @@ -1842,8 +1842,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Revokes roles from another role." << endl; + std::string help() const override { + return "Revokes roles from another role."; } virtual Status checkAuthForCommand(Client* client, @@ -1926,12 +1926,11 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Drops a single role. Before deleting the role completely it must remove it " - "from any users or roles that reference it. If any errors occur in the middle " - "of that process it's possible to be left in a state where the role has been " - "removed from some user/roles but otherwise still exists." - << endl; + std::string help() const override { + return "Drops a single role. Before deleting the role completely it must remove it " + "from any users or roles that reference it. If any errors occur in the middle " + "of that process it's possible to be left in a state where the role has been " + "removed from some user/roles but otherwise still exists."; } virtual Status checkAuthForCommand(Client* client, @@ -2069,13 +2068,12 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Drops all roles from the given database. Before deleting the roles completely " - "it must remove them from any users or other roles that reference them. If any " - "errors occur in the middle of that process it's possible to be left in a state " - "where the roles have been removed from some user/roles but otherwise still " - "exist." - << endl; + std::string help() const override { + return "Drops all roles from the given database. Before deleting the roles completely " + "it must remove them from any users or other roles that reference them. If any " + "errors occur in the middle of that process it's possible to be left in a state " + "where the roles have been removed from some user/roles but otherwise still " + "exist."; } virtual Status checkAuthForCommand(Client* client, @@ -2207,8 +2205,8 @@ public: CmdRolesInfo() : BasicCommand("rolesInfo") {} - virtual void help(stringstream& ss) const { - ss << "Returns information about roles." << endl; + std::string help() const override { + return "Returns information about roles."; } virtual Status checkAuthForCommand(Client* client, @@ -2296,8 +2294,8 @@ public: CmdInvalidateUserCache() : BasicCommand("invalidateUserCache") {} - virtual void help(stringstream& ss) const { - ss << "Invalidates the in-memory cache of user information" << endl; + std::string help() const override { + return "Invalidates the in-memory cache of user information"; } virtual Status checkAuthForCommand(Client* client, @@ -2333,8 +2331,8 @@ public: CmdGetCacheGeneration() : BasicCommand("_getUserCacheGeneration") {} - virtual void help(stringstream& ss) const { - ss << "internal" << endl; + std::string help() const override { + return "internal"; } virtual Status checkAuthForCommand(Client* client, @@ -2380,8 +2378,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Internal command used by mongorestore for updating user/role data" << endl; + std::string help() const override { + return "Internal command used by mongorestore for updating user/role data"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/commands/validate.cpp b/src/mongo/db/commands/validate.cpp index 5fb1690b34f..f3d04650286 100644 --- a/src/mongo/db/commands/validate.cpp +++ b/src/mongo/db/commands/validate.cpp @@ -71,12 +71,12 @@ public: return true; } - virtual void help(stringstream& h) const { - h << "Validate contents of a namespace by scanning its data structures for correctness. " - "Slow.\n" - "Add full:true option to do a more thorough check\n" - "Add scandata:false to skip the scan of the collection data without skipping scans " - "of any indexes"; + std::string help() const override { + return "Validate contents of a namespace by scanning its data structures for correctness. " + "Slow.\n" + "Add full:true option to do a more thorough check\n" + "Add scandata:false to skip the scan of the collection data without skipping scans " + "of any indexes"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp index e3f9c60774d..922c5a57652 100644 --- a/src/mongo/db/commands/write_commands/write_commands.cpp +++ b/src/mongo/db/commands/write_commands/write_commands.cpp @@ -246,8 +246,8 @@ public: redactTooLongLog(cmdObj, "documents"); } - void help(std::stringstream& help) const final { - help << "insert documents"; + std::string help() const final { + return "insert documents"; } Status checkAuthForRequest(OperationContext* opCtx, const OpMsgRequest& request) final { @@ -277,8 +277,8 @@ public: redactTooLongLog(cmdObj, "updates"); } - void help(std::stringstream& help) const final { - help << "update documents"; + std::string help() const final { + return "update documents"; } Status checkAuthForRequest(OperationContext* opCtx, const OpMsgRequest& request) final { @@ -344,8 +344,8 @@ public: redactTooLongLog(cmdObj, "deletes"); } - void help(std::stringstream& help) const final { - help << "delete documents"; + std::string help() const final { + return "delete documents"; } Status checkAuthForRequest(OperationContext* opCtx, const OpMsgRequest& request) final { diff --git a/src/mongo/db/exec/stagedebug_cmd.cpp b/src/mongo/db/exec/stagedebug_cmd.cpp index d0b20203eff..df3e78671df 100644 --- a/src/mongo/db/exec/stagedebug_cmd.cpp +++ b/src/mongo/db/exec/stagedebug_cmd.cpp @@ -129,7 +129,9 @@ public: bool slaveOverrideOk() const { return false; } - void help(std::stringstream& h) const {} + std::string help() const override { + return {}; + } virtual void addRequiredPrivileges(const std::string& dbname, const BSONObj& cmdObj, diff --git a/src/mongo/db/ftdc/ftdc_commands.cpp b/src/mongo/db/ftdc/ftdc_commands.cpp index ba6d7c92af2..3bd4a75e256 100644 --- a/src/mongo/db/ftdc/ftdc_commands.cpp +++ b/src/mongo/db/ftdc/ftdc_commands.cpp @@ -53,8 +53,8 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "get latest diagnostic data collection snapshot"; + std::string help() const override { + return "get latest diagnostic data collection snapshot"; } bool slaveOk() const override { diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp index 63210ca1bed..c0e22a2221a 100644 --- a/src/mongo/db/repl/master_slave.cpp +++ b/src/mongo/db/repl/master_slave.cpp @@ -361,8 +361,8 @@ void ReplSource::forceResyncDead(OperationContext* opCtx, const char* requester) class HandshakeCmd : public BasicCommand { public: - void help(stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } HandshakeCmd() : BasicCommand("handshake") {} virtual bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp index f9917d98177..c0b16b9e9b5 100644 --- a/src/mongo/db/repl/repl_set_commands.cpp +++ b/src/mongo/db/repl/repl_set_commands.cpp @@ -86,8 +86,8 @@ public: // Testing only, enabled via command-line. class CmdReplSetTest : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "Just for tests.\n"; + std::string help() const override { + return "Just for tests.\n"; } // No auth needed because it only works when enabled via command line. virtual Status checkAuthForCommand(Client* client, @@ -183,10 +183,10 @@ public: class CmdReplSetGetStatus : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "Report status of a replica set from the POV of this server\n"; - help << "{ replSetGetStatus : 1 }"; - help << "\nhttp://dochub.mongodb.org/core/replicasetcommands"; + std::string help() const override { + return "Report status of a replica set from the POV of this server\n" + "{ replSetGetStatus : 1 }\n" + "http://dochub.mongodb.org/core/replicasetcommands"; } CmdReplSetGetStatus() : ReplSetCommand("replSetGetStatus") {} virtual bool run(OperationContext* opCtx, @@ -224,10 +224,10 @@ private: class CmdReplSetGetConfig : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "Returns the current replica set configuration"; - help << "{ replSetGetConfig : 1 }"; - help << "\nhttp://dochub.mongodb.org/core/replicasetcommands"; + std::string help() const override { + return "Returns the current replica set configuration" + "{ replSetGetConfig : 1 }\n" + "http://dochub.mongodb.org/core/replicasetcommands"; } CmdReplSetGetConfig() : ReplSetCommand("replSetGetConfig") {} virtual bool run(OperationContext* opCtx, @@ -342,9 +342,9 @@ void parseReplSetSeedList(ReplicationCoordinatorExternalState* externalState, class CmdReplSetInitiate : public ReplSetCommand { public: CmdReplSetInitiate() : ReplSetCommand("replSetInitiate") {} - virtual void help(stringstream& h) const { - h << "Initiate/christen a replica set."; - h << "\nhttp://dochub.mongodb.org/core/replicasetcommands"; + std::string help() const override { + return "Initiate/christen a replica set.\n" + "http://dochub.mongodb.org/core/replicasetcommands"; } virtual bool run(OperationContext* opCtx, const string&, @@ -416,10 +416,10 @@ private: class CmdReplSetReconfig : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "Adjust configuration of a replica set\n"; - help << "{ replSetReconfig : config_object }"; - help << "\nhttp://dochub.mongodb.org/core/replicasetcommands"; + std::string help() const override { + return "Adjust configuration of a replica set\n" + "{ replSetReconfig : config_object }\n" + "http://dochub.mongodb.org/core/replicasetcommands"; } CmdReplSetReconfig() : ReplSetCommand("replSetReconfig") {} virtual bool run(OperationContext* opCtx, @@ -468,15 +468,15 @@ private: class CmdReplSetFreeze : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "{ replSetFreeze : <seconds> }"; - help << "'freeze' state of member to the extent we can do that. What this really means is " - "that\n"; - help << "this node will not attempt to become primary until the time period specified " - "expires.\n"; - help << "You can call again with {replSetFreeze:0} to unfreeze sooner.\n"; - help << "A process restart unfreezes the member also.\n"; - help << "\nhttp://dochub.mongodb.org/core/replicasetcommands"; + std::string help() const override { + return "{ replSetFreeze : <seconds> }\n" + "'freeze' state of member to the extent we can do that. What this really means is " + "that\n" + "this node will not attempt to become primary until the time period specified " + "expires.\n" + "You can call again with {replSetFreeze:0} to unfreeze sooner.\n" + "A process restart unfreezes the member also.\n" + "http://dochub.mongodb.org/core/replicasetcommands"; } CmdReplSetFreeze() : ReplSetCommand("replSetFreeze") {} virtual bool run(OperationContext* opCtx, @@ -500,13 +500,13 @@ private: class CmdReplSetStepDown : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "{ replSetStepDown : <seconds> }\n"; - help << "Step down as primary. Will not try to reelect self for the specified time period " - "(1 minute if no numeric secs value specified, or secs is 0).\n"; - help << "(If another member with same priority takes over in the meantime, it will stay " - "primary.)\n"; - help << "http://dochub.mongodb.org/core/replicasetcommands"; + std::string help() const override { + return "{ replSetStepDown : <seconds> }\n" + "Step down as primary. Will not try to reelect self for the specified time period " + "(1 minute if no numeric secs value specified, or secs is 0).\n" + "(If another member with same priority takes over in the meantime, it will stay " + "primary.)\n" + "http://dochub.mongodb.org/core/replicasetcommands"; } CmdReplSetStepDown() : ReplSetCommand("replSetStepDown") {} virtual bool run(OperationContext* opCtx, @@ -568,9 +568,9 @@ private: class CmdReplSetMaintenance : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "{ replSetMaintenance : bool }\n"; - help << "Enable or disable maintenance mode."; + std::string help() const override { + return "{ replSetMaintenance : bool }\n" + "Enable or disable maintenance mode."; } CmdReplSetMaintenance() : ReplSetCommand("replSetMaintenance") {} virtual bool run(OperationContext* opCtx, @@ -595,10 +595,10 @@ private: class CmdReplSetSyncFrom : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "{ replSetSyncFrom : \"host:port\" }\n"; - help << "Change who this member is syncing from. Note: This will interrupt and restart an " - "in-progress initial sync."; + std::string help() const override { + return "{ replSetSyncFrom : \"host:port\" }\n" + "Change who this member is syncing from. Note: This will interrupt and restart an " + "in-progress initial sync."; } CmdReplSetSyncFrom() : ReplSetCommand("replSetSyncFrom") {} virtual bool run(OperationContext* opCtx, @@ -872,10 +872,10 @@ private: class CmdReplSetAbortPrimaryCatchUp : public ReplSetCommand { public: - virtual void help(stringstream& help) const { - help << "{ CmdReplSetAbortPrimaryCatchUp : 1 }\n"; - help << "Abort primary catch-up mode; immediately finish the transition to primary " - "without fetching any further unreplicated writes from any other online nodes"; + std::string help() const override { + return "{ CmdReplSetAbortPrimaryCatchUp : 1 }\n" + "Abort primary catch-up mode; immediately finish the transition to primary " + "without fetching any further unreplicated writes from any other online nodes"; } CmdReplSetAbortPrimaryCatchUp() : ReplSetCommand("replSetAbortPrimaryCatchUp") {} diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index b33a9e54d46..69c969231ce 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -219,10 +219,10 @@ public: virtual bool slaveOk() const { return true; } - virtual void help(stringstream& help) const { - help << "Check if this server is primary for a replica pair/set; also if it is --master or " - "--slave in simple master/slave setups.\n"; - help << "{ isMaster : 1 }"; + std::string help() const override { + return "Check if this server is primary for a replica pair/set; also if it is --master or " + "--slave in simple master/slave setups.\n" + "{ isMaster : 1 }"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; diff --git a/src/mongo/db/repl/resync.cpp b/src/mongo/db/repl/resync.cpp index 3c946eea040..ccc566d63c3 100644 --- a/src/mongo/db/repl/resync.cpp +++ b/src/mongo/db/repl/resync.cpp @@ -66,8 +66,8 @@ public: out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - void help(stringstream& h) const { - h << "resync (from scratch) a stale slave or replica set secondary node.\n"; + std::string help() const override { + return "resync (from scratch) a stale slave or replica set secondary node.\n"; } CmdResync() : ErrmsgCommandDeprecated(kResyncFieldName) {} diff --git a/src/mongo/db/s/check_sharding_index_command.cpp b/src/mongo/db/s/check_sharding_index_command.cpp index 2d1e0e674da..9d3afd68c8e 100644 --- a/src/mongo/db/s/check_sharding_index_command.cpp +++ b/src/mongo/db/s/check_sharding_index_command.cpp @@ -59,8 +59,8 @@ class CheckShardingIndex : public ErrmsgCommandDeprecated { public: CheckShardingIndex() : ErrmsgCommandDeprecated("checkShardingIndex") {} - virtual void help(std::stringstream& help) const { - help << "Internal command.\n"; + std::string help() const override { + return "Internal command.\n"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/s/config/configsvr_add_shard_command.cpp b/src/mongo/db/s/config/configsvr_add_shard_command.cpp index 329c24127ce..c6354590788 100644 --- a/src/mongo/db/s/config/configsvr_add_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_add_shard_command.cpp @@ -60,9 +60,9 @@ class ConfigSvrAddShardCommand : public BasicCommand { public: ConfigSvrAddShardCommand() : BasicCommand("_configsvrAddShard") {} - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Validates and adds a new shard to the cluster."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Validates and adds a new shard to the cluster."; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp b/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp index 910401f2825..391aa557867 100644 --- a/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp +++ b/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp @@ -60,9 +60,9 @@ class ConfigSvrAddShardToZoneCommand : public BasicCommand { public: ConfigSvrAddShardToZoneCommand() : BasicCommand("_configsvrAddShardToZone") {} - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Validates and adds a new zone to the shard."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Validates and adds a new zone to the shard."; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp b/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp index 49b01f5454f..134032e61c4 100644 --- a/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp +++ b/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp @@ -87,8 +87,8 @@ class ConfigSvrCommitChunkMigrationCommand : public BasicCommand { public: ConfigSvrCommitChunkMigrationCommand() : BasicCommand("_configsvrCommitChunkMigration") {} - void help(std::stringstream& help) const override { - help << "should not be calling this directly"; + std::string help() const override { + return "should not be calling this directly"; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp index f264d07b821..19b1fb0f263 100644 --- a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp +++ b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp @@ -45,9 +45,9 @@ class ConfigSvrBalancerControlCommand : public BasicCommand { public: ConfigSvrBalancerControlCommand(StringData name) : BasicCommand(name) {} - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Controls the balancer state."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Controls the balancer state."; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_create_database_command.cpp b/src/mongo/db/s/config/configsvr_create_database_command.cpp index a95c6748860..556c6b5e0a2 100644 --- a/src/mongo/db/s/config/configsvr_create_database_command.cpp +++ b/src/mongo/db/s/config/configsvr_create_database_command.cpp @@ -75,9 +75,9 @@ public: return true; } - virtual void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Create a database."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Create a database."; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp index 8d95559e1fa..7bd0bdbd541 100644 --- a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp @@ -72,9 +72,9 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Drops a collection from a database."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Drops a collection from a database."; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/s/config/configsvr_drop_database_command.cpp b/src/mongo/db/s/config/configsvr_drop_database_command.cpp index 7f1db2ca2f8..cef41aa0d57 100644 --- a/src/mongo/db/s/config/configsvr_drop_database_command.cpp +++ b/src/mongo/db/s/config/configsvr_drop_database_command.cpp @@ -66,9 +66,9 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Drops a database."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Drops a database."; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp b/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp index cc60ec19b77..2cb4670595f 100644 --- a/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp +++ b/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp @@ -73,9 +73,9 @@ public: return true; } - virtual void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Enable sharding on a database."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Enable sharding on a database."; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp b/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp index 4f7f06c5176..3fb76ac3056 100644 --- a/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp @@ -67,9 +67,9 @@ class ConfigSvrMergeChunkCommand : public BasicCommand { public: ConfigSvrMergeChunkCommand() : BasicCommand("_configsvrCommitChunkMerge") {} - void help(std::stringstream& help) const override { - help << "Internal command, which is sent by a shard to the sharding config server. Do " - "not call directly. Receives, validates, and processes a MergeChunkRequest"; + std::string help() const override { + return "Internal command, which is sent by a shard to the sharding config server. Do " + "not call directly. Receives, validates, and processes a MergeChunkRequest"; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp index 7156a604fd5..904185e754a 100644 --- a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp @@ -51,9 +51,9 @@ class ConfigSvrMoveChunkCommand : public BasicCommand { public: ConfigSvrMoveChunkCommand() : BasicCommand("_configsvrMoveChunk") {} - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Requests the balancer to move or rebalance a single chunk."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Requests the balancer to move or rebalance a single chunk."; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_move_primary_command.cpp b/src/mongo/db/s/config/configsvr_move_primary_command.cpp index e9042865c64..7f5b3a4169d 100644 --- a/src/mongo/db/s/config/configsvr_move_primary_command.cpp +++ b/src/mongo/db/s/config/configsvr_move_primary_command.cpp @@ -80,9 +80,9 @@ public: return true; } - virtual void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Reassigns the primary shard of a database."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Reassigns the primary shard of a database."; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp index ae0b3e070aa..e8d089c9370 100644 --- a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp @@ -57,9 +57,9 @@ class ConfigSvrRemoveShardCommand : public BasicCommand { public: ConfigSvrRemoveShardCommand() : BasicCommand("_configsvrRemoveShard") {} - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Removes a shard from the cluster."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Removes a shard from the cluster."; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp b/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp index f40b1059734..7656550edff 100644 --- a/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp @@ -60,9 +60,9 @@ class ConfigSvrRemoveShardFromZoneCommand : public BasicCommand { public: ConfigSvrRemoveShardFromZoneCommand() : BasicCommand("_configsvrRemoveShardFromZone") {} - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Validates and removes the shard from the zone."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Validates and removes the shard from the zone."; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp index 00cfa9f1710..b602fed5350 100644 --- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp @@ -718,10 +718,10 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - << "directly. Shards a collection. Requires key. Optional unique. Sharding must " - "already be enabled for the database"; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Shards a collection. Requires key. Optional unique. Sharding must " + "already be enabled for the database"; } std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const override { diff --git a/src/mongo/db/s/config/configsvr_split_chunk_command.cpp b/src/mongo/db/s/config/configsvr_split_chunk_command.cpp index 4740525ee23..b3f536871e5 100644 --- a/src/mongo/db/s/config/configsvr_split_chunk_command.cpp +++ b/src/mongo/db/s/config/configsvr_split_chunk_command.cpp @@ -65,9 +65,9 @@ class ConfigSvrSplitChunkCommand : public BasicCommand { public: ConfigSvrSplitChunkCommand() : BasicCommand("_configsvrCommitChunkSplit") {} - void help(std::stringstream& help) const override { - help << "Internal command, which is sent by a shard to the sharding config server. Do " - "not call directly. Receives, validates, and processes a SplitChunkRequest."; + std::string help() const override { + return "Internal command, which is sent by a shard to the sharding config server. Do " + "not call directly. Receives, validates, and processes a SplitChunkRequest."; } bool slaveOk() const override { diff --git a/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp b/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp index 88c6465b5a2..ed83028907d 100644 --- a/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp +++ b/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp @@ -62,9 +62,9 @@ class ConfigsvrUpdateZoneKeyRangeCommand : public BasicCommand { public: ConfigsvrUpdateZoneKeyRangeCommand() : BasicCommand("_configsvrUpdateZoneKeyRange") {} - void help(std::stringstream& help) const override { - help << "Internal command, which is exported by the sharding config server. Do not call " - "directly. Validates and assigns a new range to a zone."; + std::string help() const override { + return "Internal command, which is exported by the sharding config server. Do not call " + "directly. Validates and assigns a new range to a zone."; } bool slaveOk() const override { diff --git a/src/mongo/db/s/flush_routing_table_cache_updates_command.cpp b/src/mongo/db/s/flush_routing_table_cache_updates_command.cpp index e24808b412c..8c4732c1dea 100644 --- a/src/mongo/db/s/flush_routing_table_cache_updates_command.cpp +++ b/src/mongo/db/s/flush_routing_table_cache_updates_command.cpp @@ -57,13 +57,13 @@ public: FlushRoutingTableCacheUpdates() : BasicCommand("_flushRoutingTableCacheUpdates", "forceRoutingTableRefresh") {} - void help(std::stringstream& help) const override { - help << "Internal command which waits for any pending routing table cache updates for a " - "particular namespace to be written locally. The operationTime returned in the " - "response metadata is guaranteed to be at least as late as the last routing table " - "cache update to the local disk. Takes a 'forceRemoteRefresh' option to make this " - "node refresh its cache from the config server before waiting for the last refresh " - "to be persisted."; + std::string help() const override { + return "Internal command which waits for any pending routing table cache updates for a " + "particular namespace to be written locally. The operationTime returned in the " + "response metadata is guaranteed to be at least as late as the last routing table " + "cache update to the local disk. Takes a 'forceRemoteRefresh' option to make this " + "node refresh its cache from the config server before waiting for the last refresh " + "to be persisted."; } bool adminOnly() const override { diff --git a/src/mongo/db/s/get_shard_version_command.cpp b/src/mongo/db/s/get_shard_version_command.cpp index 65ab0f0b652..4ce02d070a6 100644 --- a/src/mongo/db/s/get_shard_version_command.cpp +++ b/src/mongo/db/s/get_shard_version_command.cpp @@ -50,8 +50,8 @@ class GetShardVersion : public BasicCommand { public: GetShardVersion() : BasicCommand("getShardVersion") {} - void help(std::stringstream& help) const override { - help << " example: { getShardVersion : 'alleyinsider.foo' } "; + std::string help() const override { + return " example: { getShardVersion : 'alleyinsider.foo' } "; } bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/s/merge_chunks_command.cpp b/src/mongo/db/s/merge_chunks_command.cpp index 4e8c9c768e0..5b7e68fda56 100644 --- a/src/mongo/db/s/merge_chunks_command.cpp +++ b/src/mongo/db/s/merge_chunks_command.cpp @@ -309,10 +309,10 @@ class MergeChunksCommand : public ErrmsgCommandDeprecated { public: MergeChunksCommand() : ErrmsgCommandDeprecated("mergeChunks") {} - void help(std::stringstream& h) const override { - h << "Merge Chunks command\n" - << "usage: { mergeChunks : <ns>, bounds : [ <min key>, <max key> ]," - << " (opt) epoch : <epoch> }"; + std::string help() const override { + return "Merge Chunks command\n" + "usage: { mergeChunks : <ns>, bounds : [ <min key>, <max key> ]," + " (opt) epoch : <epoch> }"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp index a22d83f15f5..785a3309d22 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy_commands.cpp @@ -117,8 +117,8 @@ class InitialCloneCommand : public BasicCommand { public: InitialCloneCommand() : BasicCommand("_migrateClone") {} - void help(std::stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { @@ -179,8 +179,8 @@ class TransferModsCommand : public BasicCommand { public: TransferModsCommand() : BasicCommand("_transferMods") {} - void help(std::stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { @@ -228,8 +228,8 @@ class MigrateSessionCommand : public BasicCommand { public: MigrateSessionCommand() : BasicCommand("_getNextSessionMods") {} - void help(std::stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp index c598a5db337..d4b235f251f 100644 --- a/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp +++ b/src/mongo/db/s/migration_destination_manager_legacy_commands.cpp @@ -59,8 +59,8 @@ class RecvChunkStartCommand : public ErrmsgCommandDeprecated { public: RecvChunkStartCommand() : ErrmsgCommandDeprecated("_recvChunkStart") {} - void help(std::stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } virtual bool slaveOk() const { @@ -159,8 +159,8 @@ class RecvChunkStatusCommand : public BasicCommand { public: RecvChunkStatusCommand() : BasicCommand("_recvChunkStatus") {} - void help(std::stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } virtual bool slaveOk() const { @@ -197,8 +197,8 @@ class RecvChunkCommitCommand : public BasicCommand { public: RecvChunkCommitCommand() : BasicCommand("_recvChunkCommit") {} - void help(std::stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } virtual bool slaveOk() const { @@ -243,8 +243,8 @@ class RecvChunkAbortCommand : public BasicCommand { public: RecvChunkAbortCommand() : BasicCommand("_recvChunkAbort") {} - void help(std::stringstream& h) const { - h << "internal"; + std::string help() const override { + return "internal"; } virtual bool slaveOk() const { diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp index c2dbc58e076..5233290efc2 100644 --- a/src/mongo/db/s/move_chunk_command.cpp +++ b/src/mongo/db/s/move_chunk_command.cpp @@ -76,8 +76,8 @@ class MoveChunkCommand : public BasicCommand { public: MoveChunkCommand() : BasicCommand("moveChunk") {} - void help(std::stringstream& help) const override { - help << "should not be calling this directly"; + std::string help() const override { + return "should not be calling this directly"; } bool slaveOk() const override { diff --git a/src/mongo/db/s/set_shard_version_command.cpp b/src/mongo/db/s/set_shard_version_command.cpp index 61ab7ece2b1..7ddd6d2f6a1 100644 --- a/src/mongo/db/s/set_shard_version_command.cpp +++ b/src/mongo/db/s/set_shard_version_command.cpp @@ -62,8 +62,8 @@ class SetShardVersion : public ErrmsgCommandDeprecated { public: SetShardVersion() : ErrmsgCommandDeprecated("setShardVersion") {} - void help(std::stringstream& help) const override { - help << "internal"; + std::string help() const override { + return "internal"; } bool adminOnly() const override { diff --git a/src/mongo/db/s/split_chunk_command.cpp b/src/mongo/db/s/split_chunk_command.cpp index 4d0060cb941..8de8e6dc966 100644 --- a/src/mongo/db/s/split_chunk_command.cpp +++ b/src/mongo/db/s/split_chunk_command.cpp @@ -57,11 +57,11 @@ class SplitChunkCommand : public ErrmsgCommandDeprecated { public: SplitChunkCommand() : ErrmsgCommandDeprecated("splitChunk") {} - void help(std::stringstream& help) const override { - help << "internal command usage only\n" - "example:\n" - " { splitChunk:\"db.foo\" , keyPattern: {a:1} , min : {a:100} , max: {a:200} { " - "splitKeys : [ {a:150} , ... ]}"; + std::string help() const override { + return "internal command usage only\n" + "example:\n" + " { splitChunk:\"db.foo\" , keyPattern: {a:1} , min : {a:100} , max: {a:200} { " + "splitKeys : [ {a:150} , ... ]}"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/s/split_vector_command.cpp b/src/mongo/db/s/split_vector_command.cpp index 3a6fed519ec..4ac78111bf7 100644 --- a/src/mongo/db/s/split_vector_command.cpp +++ b/src/mongo/db/s/split_vector_command.cpp @@ -53,19 +53,19 @@ public: return false; } - void help(stringstream& help) const override { - help << "Internal command.\n" - "examples:\n" - " { splitVector : \"blog.post\" , keyPattern:{x:1} , min:{x:10} , max:{x:20}, " - "maxChunkSize:200 }\n" - " maxChunkSize unit in MBs\n" - " May optionally specify 'maxSplitPoints' and 'maxChunkObjects' to avoid " - "traversing the whole chunk\n" - " \n" - " { splitVector : \"blog.post\" , keyPattern:{x:1} , min:{x:10} , max:{x:20}, " - "force: true }\n" - " 'force' will produce one split point even if data is small; defaults to false\n" - "NOTE: This command may take a while to run"; + std::string help() const override { + return "Internal command.\n" + "examples:\n" + " { splitVector : \"blog.post\" , keyPattern:{x:1} , min:{x:10} , max:{x:20}, " + "maxChunkSize:200 }\n" + " maxChunkSize unit in MBs\n" + " May optionally specify 'maxSplitPoints' and 'maxChunkObjects' to avoid " + "traversing the whole chunk\n" + " \n" + " { splitVector : \"blog.post\" , keyPattern:{x:1} , min:{x:10} , max:{x:20}, " + "force: true }\n" + " 'force' will produce one split point even if data is small; defaults to false\n" + "NOTE: This command may take a while to run"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/db/s/unset_sharding_command.cpp b/src/mongo/db/s/unset_sharding_command.cpp index 81c6bb6c638..5aae6e00a94 100644 --- a/src/mongo/db/s/unset_sharding_command.cpp +++ b/src/mongo/db/s/unset_sharding_command.cpp @@ -48,8 +48,8 @@ class UnsetShardingCommand : public BasicCommand { public: UnsetShardingCommand() : BasicCommand("unsetSharding") {} - void help(std::stringstream& help) const override { - help << "internal"; + std::string help() const override { + return "internal"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/storage/mmap_v1/journal_latency_test_cmd.cpp b/src/mongo/db/storage/mmap_v1/journal_latency_test_cmd.cpp index 6a94fc2d0b1..4f90ba1c6d0 100644 --- a/src/mongo/db/storage/mmap_v1/journal_latency_test_cmd.cpp +++ b/src/mongo/db/storage/mmap_v1/journal_latency_test_cmd.cpp @@ -77,8 +77,8 @@ public: virtual bool adminOnly() const { return true; } - virtual void help(stringstream& h) const { - h << "test how long to write and fsync to a test file in the journal/ directory"; + std::string help() const override { + return "test how long to write and fsync to a test file in the journal/ directory"; } // No auth needed because it only works when enabled via command line. virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/client/shard_connection.cpp b/src/mongo/s/client/shard_connection.cpp index c0405d45652..d79611871e4 100644 --- a/src/mongo/s/client/shard_connection.cpp +++ b/src/mongo/s/client/shard_connection.cpp @@ -92,8 +92,8 @@ private: class ShardedPoolStats : public BasicCommand { public: ShardedPoolStats() : BasicCommand("shardConnPoolStats") {} - virtual void help(stringstream& help) const { - help << "stats about the shard connection pool"; + std::string help() const override { + return "stats about the shard connection pool"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { return false; diff --git a/src/mongo/s/commands/cluster_add_shard_cmd.cpp b/src/mongo/s/commands/cluster_add_shard_cmd.cpp index 1fee4f8cfb9..56cdf9650ab 100644 --- a/src/mongo/s/commands/cluster_add_shard_cmd.cpp +++ b/src/mongo/s/commands/cluster_add_shard_cmd.cpp @@ -68,8 +68,8 @@ public: return true; } - virtual void help(std::stringstream& help) const { - help << "add a new shard to the system"; + std::string help() const override { + return "add a new shard to the system"; } virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_add_shard_to_zone_cmd.cpp b/src/mongo/s/commands/cluster_add_shard_to_zone_cmd.cpp index d05c086d75a..e82e6bc0817 100644 --- a/src/mongo/s/commands/cluster_add_shard_to_zone_cmd.cpp +++ b/src/mongo/s/commands/cluster_add_shard_to_zone_cmd.cpp @@ -81,8 +81,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "adds a shard to zone"; + std::string help() const override { + return "adds a shard to zone"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_control_balancer_cmd.cpp b/src/mongo/s/commands/cluster_control_balancer_cmd.cpp index 17f88f3d655..11e05a559d0 100644 --- a/src/mongo/s/commands/cluster_control_balancer_cmd.cpp +++ b/src/mongo/s/commands/cluster_control_balancer_cmd.cpp @@ -62,8 +62,8 @@ public: return false; } - void help(std::stringstream& help) const override { - help << "Starts or stops the sharding balancer."; + std::string help() const override { + return "Starts or stops the sharding balancer."; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp index fd5e6b566b6..77bdbbb6681 100644 --- a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp +++ b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp @@ -64,10 +64,10 @@ public: return true; } - virtual void help(std::stringstream& help) const { - help << "Enable sharding for a database. " - << "(Use 'shardcollection' command afterwards.)\n" - << " { enablesharding : \"<dbname>\" }\n"; + std::string help() const override { + return "Enable sharding for a database. " + "(Use 'shardcollection' command afterwards.)\n" + " { enablesharding : \"<dbname>\" }\n"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_explain_cmd.cpp b/src/mongo/s/commands/cluster_explain_cmd.cpp index a02f11943c6..b734501ab36 100644 --- a/src/mongo/s/commands/cluster_explain_cmd.cpp +++ b/src/mongo/s/commands/cluster_explain_cmd.cpp @@ -77,8 +77,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "explain database reads and writes"; + std::string help() const override { + return "explain database reads and writes"; } /** diff --git a/src/mongo/s/commands/cluster_find_cmd.cpp b/src/mongo/s/commands/cluster_find_cmd.cpp index 3f683b3bef0..9c8adb1a64b 100644 --- a/src/mongo/s/commands/cluster_find_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_cmd.cpp @@ -85,8 +85,8 @@ public: return false; } - void help(std::stringstream& help) const final { - help << "query for documents"; + std::string help() const override { + return "query for documents"; } /** diff --git a/src/mongo/s/commands/cluster_flush_router_config_cmd.cpp b/src/mongo/s/commands/cluster_flush_router_config_cmd.cpp index 89717969365..61f0f9d640a 100644 --- a/src/mongo/s/commands/cluster_flush_router_config_cmd.cpp +++ b/src/mongo/s/commands/cluster_flush_router_config_cmd.cpp @@ -52,8 +52,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "flush all router config"; + std::string help() const override { + return "flush all router config"; } virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_fsync_cmd.cpp b/src/mongo/s/commands/cluster_fsync_cmd.cpp index 4b1a4a469e5..fa6363ed9fb 100644 --- a/src/mongo/s/commands/cluster_fsync_cmd.cpp +++ b/src/mongo/s/commands/cluster_fsync_cmd.cpp @@ -55,8 +55,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "invoke fsync on all shards belonging to the cluster"; + std::string help() const override { + return "invoke fsync on all shards belonging to the cluster"; } virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_ftdc_commands.cpp b/src/mongo/s/commands/cluster_ftdc_commands.cpp index 14b087d446f..c6c30cebf95 100644 --- a/src/mongo/s/commands/cluster_ftdc_commands.cpp +++ b/src/mongo/s/commands/cluster_ftdc_commands.cpp @@ -52,8 +52,8 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "get latest diagnostic data collection snapshot"; + std::string help() const override { + return "get latest diagnostic data collection snapshot"; } bool slaveOk() const override { diff --git a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp b/src/mongo/s/commands/cluster_get_last_error_cmd.cpp index ebbaab0cc36..9665072154d 100644 --- a/src/mongo/s/commands/cluster_get_last_error_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_last_error_cmd.cpp @@ -199,8 +199,8 @@ public: return true; } - virtual void help(std::stringstream& help) const { - help << "check for an error on the last command executed"; + std::string help() const override { + return "check for an error on the last command executed"; } virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp b/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp index 3d4ed9a44ca..399eccc6684 100644 --- a/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_prev_error_cmd.cpp @@ -51,8 +51,8 @@ public: return true; } - virtual void help(std::stringstream& help) const { - help << "get previous error (since last reseterror command)"; + std::string help() const override { + return "get previous error (since last reseterror command)"; } virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_get_shard_map_cmd.cpp b/src/mongo/s/commands/cluster_get_shard_map_cmd.cpp index b264f000479..3b70cf27d94 100644 --- a/src/mongo/s/commands/cluster_get_shard_map_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_shard_map_cmd.cpp @@ -51,8 +51,8 @@ public: return true; } - virtual void help(std::stringstream& help) const { - help << "lists the set of shards known to this instance"; + std::string help() const override { + return "lists the set of shards known to this instance"; } virtual bool adminOnly() const { diff --git a/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp b/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp index 4ceb6cbcf64..c55c77ef3f8 100644 --- a/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp +++ b/src/mongo/s/commands/cluster_get_shard_version_cmd.cpp @@ -59,8 +59,8 @@ public: return false; } - void help(std::stringstream& help) const override { - help << " example: { getShardVersion : 'alleyinsider.foo' } "; + std::string help() const override { + return " example: { getShardVersion : 'alleyinsider.foo' } "; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_getmore_cmd.cpp b/src/mongo/s/commands/cluster_getmore_cmd.cpp index c90eeaff5ad..00784d5c55c 100644 --- a/src/mongo/s/commands/cluster_getmore_cmd.cpp +++ b/src/mongo/s/commands/cluster_getmore_cmd.cpp @@ -74,8 +74,8 @@ public: return false; } - void help(std::stringstream& help) const final { - help << "retrieve more documents for a cursor id"; + std::string help() const final { + return "retrieve more documents for a cursor id"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_index_filter_cmd.cpp b/src/mongo/s/commands/cluster_index_filter_cmd.cpp index 97437c8bbef..c06c42f2ce0 100644 --- a/src/mongo/s/commands/cluster_index_filter_cmd.cpp +++ b/src/mongo/s/commands/cluster_index_filter_cmd.cpp @@ -74,8 +74,8 @@ public: return false; } - void help(stringstream& ss) const { - ss << _helpText; + std::string help() const override { + return _helpText; } Status checkAuthForCommand(Client* client, const std::string& dbname, const BSONObj& cmdObj) { diff --git a/src/mongo/s/commands/cluster_is_master_cmd.cpp b/src/mongo/s/commands/cluster_is_master_cmd.cpp index 4b714e7a447..8caf0cde2c4 100644 --- a/src/mongo/s/commands/cluster_is_master_cmd.cpp +++ b/src/mongo/s/commands/cluster_is_master_cmd.cpp @@ -57,8 +57,8 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "test if this is master half of a replica pair"; + std::string help() const override { + return "test if this is master half of a replica pair"; } void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_list_databases_cmd.cpp b/src/mongo/s/commands/cluster_list_databases_cmd.cpp index 1e0d0c16778..5a6d8a16552 100644 --- a/src/mongo/s/commands/cluster_list_databases_cmd.cpp +++ b/src/mongo/s/commands/cluster_list_databases_cmd.cpp @@ -73,8 +73,8 @@ public: return false; } - void help(std::stringstream& help) const final { - help << "list databases in a cluster"; + std::string help() const override { + return "list databases in a cluster"; } /* listDatabases is always authorized, diff --git a/src/mongo/s/commands/cluster_list_shards_cmd.cpp b/src/mongo/s/commands/cluster_list_shards_cmd.cpp index 7a303fd3bb2..309c45a3be2 100644 --- a/src/mongo/s/commands/cluster_list_shards_cmd.cpp +++ b/src/mongo/s/commands/cluster_list_shards_cmd.cpp @@ -42,8 +42,8 @@ class ListShardsCmd : public BasicCommand { public: ListShardsCmd() : BasicCommand("listShards", "listshards") {} - void help(std::stringstream& help) const override { - help << "list all shards of the system"; + std::string help() const override { + return "list all shards of the system"; } bool adminOnly() const override { diff --git a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp index 8b1376ad3aa..8787beefc09 100644 --- a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp +++ b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp @@ -167,8 +167,8 @@ public: return mr::mrSupportsWriteConcern(cmd); } - void help(std::stringstream& help) const override { - help << "Runs the sharded map/reduce command"; + std::string help() const override { + return "Runs the sharded map/reduce command"; } void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp index 463203917df..abfe8fe2f08 100644 --- a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp +++ b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp @@ -56,9 +56,9 @@ class ClusterMergeChunksCommand : public ErrmsgCommandDeprecated { public: ClusterMergeChunksCommand() : ErrmsgCommandDeprecated("mergeChunks") {} - void help(std::stringstream& h) const override { - h << "Merge Chunks command\n" - << "usage: { mergeChunks : <ns>, bounds : [ <min key>, <max key> ] }"; + std::string help() const override { + return "Merge Chunks command\n" + "usage: { mergeChunks : <ns>, bounds : [ <min key>, <max key> ] }"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_move_chunk_cmd.cpp b/src/mongo/s/commands/cluster_move_chunk_cmd.cpp index 19ac5c51cea..d1a3ef74e84 100644 --- a/src/mongo/s/commands/cluster_move_chunk_cmd.cpp +++ b/src/mongo/s/commands/cluster_move_chunk_cmd.cpp @@ -67,12 +67,12 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "Example: move chunk that contains the doc {num : 7} to shard001\n" - << " { movechunk : 'test.foo' , find : { num : 7 } , to : 'shard0001' }\n" - << "Example: move chunk with lower bound 0 and upper bound 10 to shard001\n" - << " { movechunk : 'test.foo' , bounds : [ { num : 0 } , { num : 10 } ] " - << " , to : 'shard001' }\n"; + std::string help() const override { + return "Example: move chunk that contains the doc {num : 7} to shard001\n" + " { movechunk : 'test.foo' , find : { num : 7 } , to : 'shard0001' }\n" + "Example: move chunk with lower bound 0 and upper bound 10 to shard001\n" + " { movechunk : 'test.foo' , bounds : [ { num : 0 } , { num : 10 } ] " + " , to : 'shard001' }\n"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_move_primary_cmd.cpp b/src/mongo/s/commands/cluster_move_primary_cmd.cpp index a15aed40fd4..181c3a3b8fd 100644 --- a/src/mongo/s/commands/cluster_move_primary_cmd.cpp +++ b/src/mongo/s/commands/cluster_move_primary_cmd.cpp @@ -69,8 +69,8 @@ public: return true; } - virtual void help(std::stringstream& help) const { - help << " example: { moveprimary : 'foo' , to : 'localhost:9999' }"; + std::string help() const override { + return " example: { moveprimary : 'foo' , to : 'localhost:9999' }"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_multicast.cpp b/src/mongo/s/commands/cluster_multicast.cpp index 3a92b006b9b..d0d8d11c607 100644 --- a/src/mongo/s/commands/cluster_multicast.cpp +++ b/src/mongo/s/commands/cluster_multicast.cpp @@ -79,8 +79,8 @@ public: return false; } - void help(std::stringstream& help) const override { - help << "multicasts a command to hosts in a system"; + std::string help() const override { + return "multicasts a command to hosts in a system"; } // no privs because it's a test command diff --git a/src/mongo/s/commands/cluster_netstat_cmd.cpp b/src/mongo/s/commands/cluster_netstat_cmd.cpp index 1e14f9bd5ad..b8ffa72b530 100644 --- a/src/mongo/s/commands/cluster_netstat_cmd.cpp +++ b/src/mongo/s/commands/cluster_netstat_cmd.cpp @@ -53,8 +53,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << " shows status/reachability of servers in the cluster"; + std::string help() const override { + return " shows status/reachability of servers in the cluster"; } virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_pipeline_cmd.cpp b/src/mongo/s/commands/cluster_pipeline_cmd.cpp index 90a641dfd97..f9d972d4771 100644 --- a/src/mongo/s/commands/cluster_pipeline_cmd.cpp +++ b/src/mongo/s/commands/cluster_pipeline_cmd.cpp @@ -42,9 +42,9 @@ class ClusterPipelineCommand : public BasicCommand { public: ClusterPipelineCommand() : BasicCommand("aggregate") {} - void help(std::stringstream& help) const { - help << "Runs the sharded aggregation command. See " - "http://dochub.mongodb.org/core/aggregation for more details."; + std::string help() const override { + return "Runs the sharded aggregation command. See " + "http://dochub.mongodb.org/core/aggregation for more details."; } bool slaveOk() const override { diff --git a/src/mongo/s/commands/cluster_plan_cache_cmd.cpp b/src/mongo/s/commands/cluster_plan_cache_cmd.cpp index 76a4a7af53f..2e1b63653cd 100644 --- a/src/mongo/s/commands/cluster_plan_cache_cmd.cpp +++ b/src/mongo/s/commands/cluster_plan_cache_cmd.cpp @@ -66,8 +66,8 @@ public: return false; } - void help(stringstream& ss) const { - ss << _helpText; + std::string help() const override { + return _helpText; } std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const override { diff --git a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp index 4137466e5a5..51d863cc668 100644 --- a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp +++ b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp @@ -45,8 +45,8 @@ class RemoveShardCmd : public BasicCommand { public: RemoveShardCmd() : BasicCommand("removeShard", "removeshard") {} - void help(std::stringstream& help) const override { - help << "remove a shard from the system."; + std::string help() const override { + return "remove a shard from the system."; } bool slaveOk() const override { diff --git a/src/mongo/s/commands/cluster_remove_shard_from_zone_cmd.cpp b/src/mongo/s/commands/cluster_remove_shard_from_zone_cmd.cpp index cfff64d3625..0118f75ee14 100644 --- a/src/mongo/s/commands/cluster_remove_shard_from_zone_cmd.cpp +++ b/src/mongo/s/commands/cluster_remove_shard_from_zone_cmd.cpp @@ -81,8 +81,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "removes a shard from the zone"; + std::string help() const override { + return "removes a shard from the zone"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp b/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp index aba2f927bd4..913d7248d11 100644 --- a/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp +++ b/src/mongo/s/commands/cluster_repl_set_get_status_cmd.cpp @@ -53,8 +53,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "Not supported through mongos"; + std::string help() const override { + return "Not supported through mongos"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp index fa6c6475d2d..04502b0e214 100644 --- a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp +++ b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp @@ -34,6 +34,7 @@ #include "mongo/s/client/shard.h" #include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" +#include "mongo/util/mongoutils/str.h" namespace mongo { @@ -66,15 +67,16 @@ public: return true; } - virtual void help(std::stringstream& help) const { + std::string help() const override { // TODO: update this comment when FCV 3.4 is removed (SERVER-32597). - help << "Set the API version for the cluster. If set to \"" - << FeatureCompatibilityVersionCommandParser::kVersion34 - << "\", then 3.6 features are disabled. If \"" - << FeatureCompatibilityVersionCommandParser::kVersion36 - << "\", then 3.6 features are enabled, and all nodes in the cluster must be version " - << "3.6. If \"4.0\", then 4.0 features are enabled. See " - << feature_compatibility_version::kDochubLink << "."; + return str::stream() + << "Set the API version for the cluster. If set to \"" + << FeatureCompatibilityVersionCommandParser::kVersion34 + << "\", then 3.6 features are disabled. If \"" + << FeatureCompatibilityVersionCommandParser::kVersion36 + << "\", then 3.6 features are enabled, and all nodes in the cluster must be version " + << "3.6. If \"4.0\", then 4.0 features are enabled. See " + << feature_compatibility_version::kDochubLink << "."; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp index a7281fa85f9..31d230f117f 100644 --- a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp +++ b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp @@ -82,10 +82,10 @@ public: return true; } - void help(std::stringstream& help) const override { - help << "Shard a collection. Requires key. Optional unique." - << " Sharding must already be enabled for the database.\n" - << " { enablesharding : \"<dbname>\" }\n"; + std::string help() const override { + return "Shard a collection. Requires key. Optional unique." + " Sharding must already be enabled for the database.\n" + " { enablesharding : \"<dbname>\" }\n"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_shutdown_cmd.cpp b/src/mongo/s/commands/cluster_shutdown_cmd.cpp index 5918cc4dabc..a3490488eb4 100644 --- a/src/mongo/s/commands/cluster_shutdown_cmd.cpp +++ b/src/mongo/s/commands/cluster_shutdown_cmd.cpp @@ -36,9 +36,9 @@ namespace { class ClusterShutdownCmd : public CmdShutdown { public: - virtual void help(std::stringstream& help) const { - help << "shutdown the database. must be ran against admin db and " - << "either (1) ran from localhost or (2) authenticated."; + std::string help() const override { + return "shutdown the database. must be ran against admin db and " + "either (1) ran from localhost or (2) authenticated."; } virtual bool run(OperationContext* opCtx, diff --git a/src/mongo/s/commands/cluster_split_cmd.cpp b/src/mongo/s/commands/cluster_split_cmd.cpp index 44f8388cfa1..1b709cf9f95 100644 --- a/src/mongo/s/commands/cluster_split_cmd.cpp +++ b/src/mongo/s/commands/cluster_split_cmd.cpp @@ -100,12 +100,12 @@ public: return false; } - void help(std::stringstream& help) const override { - help << " example: - split the shard that contains give key\n" - << " { split : 'alleyinsider.blog.posts' , find : { ts : 1 } }\n" - << " example: - split the shard that contains the key with this as the middle\n" - << " { split : 'alleyinsider.blog.posts' , middle : { ts : 1 } }\n" - << " NOTE: this does not move the chunks, it just creates a logical separation."; + std::string help() const override { + return " example: - split the shard that contains give key\n" + " { split : 'alleyinsider.blog.posts' , find : { ts : 1 } }\n" + " example: - split the shard that contains the key with this as the middle\n" + " { split : 'alleyinsider.blog.posts' , middle : { ts : 1 } }\n" + " NOTE: this does not move the chunks, it just creates a logical separation."; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_update_zone_key_range_cmd.cpp b/src/mongo/s/commands/cluster_update_zone_key_range_cmd.cpp index 22d926ac053..0abb42b3a22 100644 --- a/src/mongo/s/commands/cluster_update_zone_key_range_cmd.cpp +++ b/src/mongo/s/commands/cluster_update_zone_key_range_cmd.cpp @@ -84,8 +84,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "assigns/remove a range of a sharded collection to a zone"; + std::string help() const override { + return "assigns/remove a range of a sharded collection to a zone"; } Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_user_management_commands.cpp b/src/mongo/s/commands/cluster_user_management_commands.cpp index 24503042928..a9d6230b8cc 100644 --- a/src/mongo/s/commands/cluster_user_management_commands.cpp +++ b/src/mongo/s/commands/cluster_user_management_commands.cpp @@ -76,8 +76,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Adds a user to the system"; + std::string help() const override { + return "Adds a user to the system"; } virtual Status checkAuthForCommand(Client* client, @@ -117,8 +117,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Used to update a user, for example to change its password"; + std::string help() const override { + return "Used to update a user, for example to change its password"; } virtual Status checkAuthForCommand(Client* client, @@ -169,8 +169,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Drops a single user."; + std::string help() const override { + return "Drops a single user."; } virtual Status checkAuthForCommand(Client* client, @@ -217,8 +217,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Drops all users for a single database."; + std::string help() const override { + return "Drops all users for a single database."; } virtual Status checkAuthForCommand(Client* client, @@ -260,8 +260,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Grants roles to a user."; + std::string help() const override { + return "Grants roles to a user."; } virtual Status checkAuthForCommand(Client* client, @@ -310,8 +310,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Revokes roles from a user."; + std::string help() const override { + return "Revokes roles from a user."; } virtual Status checkAuthForCommand(Client* client, @@ -364,8 +364,8 @@ public: CmdUsersInfo() : BasicCommand("usersInfo") {} - virtual void help(stringstream& ss) const { - ss << "Returns information about users."; + std::string help() const override { + return "Returns information about users."; } virtual Status checkAuthForCommand(Client* client, @@ -397,8 +397,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Adds a role to the system"; + std::string help() const override { + return "Adds a role to the system"; } virtual Status checkAuthForCommand(Client* client, @@ -434,8 +434,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Used to update a role"; + std::string help() const override { + return "Used to update a role"; } virtual Status checkAuthForCommand(Client* client, @@ -477,8 +477,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Grants privileges to a role"; + std::string help() const override { + return "Grants privileges to a role"; } virtual Status checkAuthForCommand(Client* client, @@ -520,8 +520,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Revokes privileges from a role"; + std::string help() const override { + return "Revokes privileges from a role"; } virtual Status checkAuthForCommand(Client* client, @@ -563,8 +563,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Grants roles to another role."; + std::string help() const override { + return "Grants roles to another role."; } virtual Status checkAuthForCommand(Client* client, @@ -606,8 +606,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Revokes roles from another role."; + std::string help() const override { + return "Revokes roles from another role."; } virtual Status checkAuthForCommand(Client* client, @@ -649,11 +649,11 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Drops a single role. Before deleting the role completely it must remove it " - "from any users or roles that reference it. If any errors occur in the middle " - "of that process it's possible to be left in a state where the role has been " - "removed from some user/roles but otherwise still exists."; + std::string help() const override { + return "Drops a single role. Before deleting the role completely it must remove it " + "from any users or roles that reference it. If any errors occur in the middle " + "of that process it's possible to be left in a state where the role has been " + "removed from some user/roles but otherwise still exists."; } virtual Status checkAuthForCommand(Client* client, @@ -695,12 +695,12 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Drops all roles from the given database. Before deleting the roles completely " - "it must remove them from any users or other roles that reference them. If any " - "errors occur in the middle of that process it's possible to be left in a state " - "where the roles have been removed from some user/roles but otherwise still " - "exist."; + std::string help() const override { + return "Drops all roles from the given database. Before deleting the roles completely " + "it must remove them from any users or other roles that reference them. If any " + "errors occur in the middle of that process it's possible to be left in a state " + "where the roles have been removed from some user/roles but otherwise still " + "exist."; } virtual Status checkAuthForCommand(Client* client, @@ -746,8 +746,8 @@ public: return false; } - virtual void help(stringstream& ss) const { - ss << "Returns information about roles."; + std::string help() const override { + return "Returns information about roles."; } virtual Status checkAuthForCommand(Client* client, @@ -783,8 +783,8 @@ public: return false; } - virtual void help(stringstream& ss) const { - ss << "Invalidates the in-memory cache of user information"; + std::string help() const override { + return "Invalidates the in-memory cache of user information"; } virtual Status checkAuthForCommand(Client* client, @@ -832,8 +832,8 @@ public: return true; } - virtual void help(stringstream& ss) const { - ss << "Internal command used by mongorestore for updating user/role data"; + std::string help() const override { + return "Internal command used by mongorestore for updating user/role data"; } virtual Status checkAuthForCommand(Client* client, diff --git a/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp index b5ecdd2f330..a44d6fbb8c1 100644 --- a/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp +++ b/src/mongo/s/commands/cluster_whats_my_uri_cmd.cpp @@ -47,8 +47,8 @@ public: return false; } - virtual void help(std::stringstream& help) const { - help << "{whatsmyuri:1}"; + std::string help() const override { + return "{whatsmyuri:1}"; } virtual void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp index a50fdd17063..bf1949d73c8 100644 --- a/src/mongo/s/commands/cluster_write_cmd.cpp +++ b/src/mongo/s/commands/cluster_write_cmd.cpp @@ -336,8 +336,8 @@ class ClusterCmdInsert : public ClusterWriteCmd { public: ClusterCmdInsert() : ClusterWriteCmd("insert", BatchedCommandRequest::BatchType_Insert) {} - void help(std::stringstream& help) const { - help << "insert documents"; + std::string help() const override { + return "insert documents"; } } clusterInsertCmd; @@ -346,8 +346,8 @@ class ClusterCmdUpdate : public ClusterWriteCmd { public: ClusterCmdUpdate() : ClusterWriteCmd("update", BatchedCommandRequest::BatchType_Update) {} - void help(std::stringstream& help) const { - help << "update documents"; + std::string help() const override { + return "update documents"; } } clusterUpdateCmd; @@ -356,8 +356,8 @@ class ClusterCmdDelete : public ClusterWriteCmd { public: ClusterCmdDelete() : ClusterWriteCmd("delete", BatchedCommandRequest::BatchType_Delete) {} - void help(std::stringstream& help) const { - help << "delete documents"; + std::string help() const override { + return "delete documents"; } } clusterDeleteCmd; diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp index 0643816ee8b..4c153831450 100644 --- a/src/mongo/s/commands/commands_public.cpp +++ b/src/mongo/s/commands/commands_public.cpp @@ -1065,8 +1065,8 @@ class DistinctCmd : public PublicGridCommand { public: DistinctCmd() : PublicGridCommand("distinct") {} - void help(stringstream& help) const override { - help << "{ distinct : 'collection name' , key : 'a.b' , query : {} }"; + std::string help() const override { + return "{ distinct : 'collection name' , key : 'a.b' , query : {} }"; } void addRequiredPrivileges(const std::string& dbname, @@ -1278,8 +1278,8 @@ class FileMD5Cmd : public PublicGridCommand { public: FileMD5Cmd() : PublicGridCommand("filemd5") {} - void help(stringstream& help) const override { - help << " example: { filemd5 : ObjectId(aaaaaaa) , root : \"fs\" }"; + std::string help() const override { + return " example: { filemd5 : ObjectId(aaaaaaa) , root : \"fs\" }"; } std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const override { @@ -1441,8 +1441,8 @@ class Geo2dFindNearCmd : public PublicGridCommand { public: Geo2dFindNearCmd() : PublicGridCommand("geoNear") {} - void help(stringstream& h) const override { - h << "http://dochub.mongodb.org/core/geo#GeospatialIndexing-geoNearCommand"; + std::string help() const override { + return "http://dochub.mongodb.org/core/geo#GeospatialIndexing-geoNearCommand"; } void addRequiredPrivileges(const std::string& dbname, diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp index 1eae00e206f..519aab14d0e 100644 --- a/src/mongo/s/commands/strategy.cpp +++ b/src/mongo/s/commands/strategy.cpp @@ -162,7 +162,7 @@ void execCommandClient(OperationContext* opCtx, if (fieldName == "help" && element.type() == Bool && element.Bool()) { std::stringstream help; help << "help for: " << c->getName() << " "; - c->help(help); + help << c->help(); result.append("help", help.str()); CommandHelpers::appendCommandStatus(result, true, ""); return; |