Esempio n. 1
0
    Status addRemoteServerToolOptions(moe::OptionSection* options) {
        options->addOptionChaining("host", "host,h", moe::String,
                "mongo host to connect to ( <set name>/s1,s2 for sets)");

        options->addOptionChaining("port", "port", moe::Int,
                "server port. Can also use --host hostname:port")
                                  .validRange(0, 65535);

        options->addOptionChaining("ipv6", "ipv6", moe::Switch,
                "enable IPv6 support (disabled by default)");


#ifdef MONGO_SSL
        Status ret = addSSLClientOptions(options);
        if (!ret.isOK()) {
            return ret;
        }
#endif

        options->addOptionChaining("username", "username,u", moe::String,
                "username");

        // We ask a user for a password if they pass in an empty string or pass --password with no
        // argument.  This must be handled when the password value is checked.
        //
        // Desired behavior:
        // --username test // Continue with username "test" and no password
        // --username test --password test // Continue with username "test" and password "test"
        // --username test --password // Continue with username "test" and prompt for password
        // --username test --password "" // Continue with username "test" and prompt for password
        //
        // To do this we pass moe::Value(std::string("")) as the "implicit value" of this option
        options->addOptionChaining("password", "password,p", moe::String, "password")
                                  .setImplicit(moe::Value(std::string("")));

        options->addOptionChaining("authenticationDatabase", "authenticationDatabase", moe::String,
                "user source (defaults to dbname)")
                                  .setDefault(moe::Value(std::string("")));

        options->addOptionChaining("authenticationMechanism", "authenticationMechanism",
                moe::String, "authentication mechanism")
                                  .setDefault(moe::Value(std::string("MONGODB-CR")));

        options->addOptionChaining("gssapiServiceName", "gssapiServiceName",
                 moe::String,
                "Service name to use when authenticating using GSSAPI/Kerberos")
            .setDefault(moe::Value(std::string(saslDefaultServiceName)));

        options->addOptionChaining("gssapiHostName", "gssapiHostName", moe::String,
                "Remote host name to use for purpose of GSSAPI/Kerberos authentication");

        return Status::OK();
    }
Esempio n. 2
0
    Status addMongoShellOptions(moe::OptionSection* options) {

        options->addOptionChaining("shell", "shell", moe::Switch,
                "run the shell after executing files");

        options->addOptionChaining("nodb", "nodb", moe::Switch,
                "don't connect to mongod on startup - no 'db address' arg expected");

        options->addOptionChaining("norc", "norc", moe::Switch,
                "will not run the \".mongorc.js\" file on start up");

        options->addOptionChaining("quiet", "quiet", moe::Switch, "be less chatty");

        options->addOptionChaining("port", "port", moe::String, "port to connect to");

        options->addOptionChaining("host", "host", moe::String, "server to connect to");

        options->addOptionChaining("eval", "eval", moe::String, "evaluate javascript");

        options->addOptionChaining("username", "username,u", moe::String,
                "username for authentication");

        options->addOptionChaining("password", "password,p", moe::String,
                "password for authentication")
                                  .setImplicit(moe::Value(std::string("")));

        options->addOptionChaining("authenticationDatabase", "authenticationDatabase", moe::String,
                "user source (defaults to dbname)")
                                  .setDefault(moe::Value(std::string("")));

        options->addOptionChaining("authenticationMechanism", "authenticationMechanism",
                moe::String, "authentication mechanism")
                                  .setDefault(moe::Value(std::string("MONGODB-CR")));

        options->addOptionChaining("help", "help,h", moe::Switch, "show this usage information");

        options->addOptionChaining("version", "version", moe::Switch, "show version information");

        options->addOptionChaining("verbose", "verbose", moe::Switch, "increase verbosity");

        options->addOptionChaining("ipv6", "ipv6", moe::Switch,
                "enable IPv6 support (disabled by default)");

        Status ret = Status::OK();
#ifdef MONGO_SSL
        ret = addSSLClientOptions(options);
        if (!ret.isOK()) {
            return ret;
        }
#endif

        options->addOptionChaining("dbaddress", "dbaddress", moe::String, "dbaddress")
                                  .hidden()
                                  .positional(1, 1);

        options->addOptionChaining("files", "files", moe::StringVector, "files")
                                  .hidden()
                                  .positional(2, -1);

        // for testing, kill op will also be disabled automatically if the tests starts a mongo
        // program
        options->addOptionChaining("nokillop", "nokillop", moe::Switch, "nokillop")
                                  .hidden();

        // for testing, will kill op without prompting
        options->addOptionChaining("autokillop", "autokillop", moe::Switch, "autokillop")
                                  .hidden();

        options->addOptionChaining("useLegacyWriteOps",
                                   "useLegacyWriteOps",
                                   moe::Switch,
                                   "use legacy write ops instead of write commands").hidden();

        options->addOptionChaining("writeMode",
                                   "writeMode",
                                   moe::String,
                                   "mode to determine how writes are done:"
                                   " commands, compatibility, legacy").hidden();

        return Status::OK();
    }
Esempio n. 3
0
    Status addMongoShellOptions(moe::OptionSection* options) {

        typedef moe::OptionDescription OD;
        typedef moe::PositionalOptionDescription POD;

        Status ret = options->addOption(OD("shell", "shell", moe::Switch,
                    "run the shell after executing files", true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("nodb", "nodb", moe::Switch,
                    "don't connect to mongod on startup - no 'db address' arg expected", true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("norc", "norc", moe::Switch,
                    "will not run the \".mongorc.js\" file on start up", true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("quiet", "quiet", moe::Switch, "be less chatty", true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("port", "port", moe::String, "port to connect to" , true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("host", "host", moe::String, "server to connect to" , true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("eval", "eval", moe::String, "evaluate javascript" , true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("username", "username,u", moe::String,
                    "username for authentication" , true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("password", "password,p", moe::String,
                    "password for authentication" , true, moe::Value(),
                    moe::Value(std::string(""))));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("authenticationDatabase", "authenticationDatabase", moe::String,
                    "user source (defaults to dbname)" , true, moe::Value(std::string(""))));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("authenticationMechanism", "authenticationMechanism",
                    moe::String, "authentication mechanism", true,
                    moe::Value(std::string("MONGODB-CR"))));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("help", "help,h", moe::Switch, "show this usage information",
                    true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("version", "version", moe::Switch, "show version information",
                    true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("verbose", "verbose", moe::Switch, "increase verbosity", true));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("ipv6", "ipv6", moe::Switch,
                    "enable IPv6 support (disabled by default)", true));
        if (!ret.isOK()) {
            return ret;
        }

#ifdef MONGO_SSL
        ret = addSSLClientOptions(options);
        if (!ret.isOK()) {
            return ret;
        }
#endif

        ret = options->addOption(OD("dbaddress", "dbaddress", moe::String, "dbaddress" , false));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("files", "files", moe::StringVector, "files" , false));
        if (!ret.isOK()) {
            return ret;
        }
        // for testing, kill op will also be disabled automatically if the tests starts a mongo
        // program
        ret = options->addOption(OD("nokillop", "nokillop", moe::Switch, "nokillop", false));
        if (!ret.isOK()) {
            return ret;
        }
        // for testing, will kill op without prompting
        ret = options->addOption(OD("autokillop", "autokillop", moe::Switch, "autokillop", false));
        if (!ret.isOK()) {
            return ret;
        }

        ret = options->addPositionalOption(POD("dbaddress", moe::String, 1));
        if (!ret.isOK()) {
            return ret;
        }
        ret = options->addPositionalOption(POD("files", moe::String, -1));
        if (!ret.isOK()) {
            return ret;
        }

        return Status::OK();
    }