Exemple #1
0
void getOptions(
    OptionManager &om,
    int &argc,
    char **argv)
{
    static struct OptionRow optionTable[] =
    {
        {"repositoryPath", "", true,
            Option::STRING, 0, 0, "r", "Repository path"},
        {"parent", "", false,
            Option::STRING, 0, 0, "p", "Parent namespace (optional)."
                "Parent namespace will be modified to be shareable if"
                " it was not already shareable"},
        {"namespaceName", "", true,
            Option::STRING, 0, 0, "n", "Namespace name"},
        {"location", "", true,
            Option::STRING, 0, 0, "l", "Remote location"},
        {"shareable", "true", false,
            Option::STRING, 0, 0, "s", "Specifies whether the"
                " namespace can shareable or not"},
        {"updatesAllowed", "false", false,
            Option::STRING, 0, 0, "u", "Specifies whether the "
                "updates to the namespace are allowed or not"}
    };
    const Uint32 NUM_OPTIONS = sizeof(optionTable)/ sizeof(optionTable[0]);
    om.registerOptions(optionTable, NUM_OPTIONS);
    om.mergeCommandLine(argc, argv);
    om.checkRequiredOptions();
}
/** GetOptions function - This function defines the Options Table
    and sets up the options from that table using the option manager.
    const char* optionName;
    const char* defaultValue;
    int required;
    Option::Type type;
    char** domain;
    Uint32 domainSize;
    const char* commandLineOptionName;
    const char* optionHelpMessage;

*/
void GetOptions(
    OptionManager& om,
    int& argc,
    char** argv,
    const String& pegasusHome)
{
    static struct OptionRow optionsTable[] =
    // optionname defaultvalue rqd  type domain domainsize clname hlpmsg
    {
        {"active", "false", false, Option::BOOLEAN, 0, 0, "a",
            "If set allows test that modify the repository"},

        {"repeat", "1", false, Option::WHOLE_NUMBER, 0, 0, "r",
            "Specifies a Repeat Count Entire test repeated this many times"},

        {"namespace", "root/cimv2", false, Option::STRING, 0, 0, "-n",
            "specifies namespace to use for test"},

        {"version", "false", false, Option::BOOLEAN, 0, 0, "v",
            "Displays TestClient Version "},

        {"verbose", "false", false, Option::BOOLEAN, 0, 0, "verbose",
            "If set, outputs extra information "},

        {"help", "false", false, Option::BOOLEAN, 0, 0, "h",
            "Prints help message with command line options "},
        {"debug", "false", false, Option::BOOLEAN, 0, 0, "d",
            "Not Used "},
#ifdef PEGASUS_HAS_SSL
        {"ssl", "false", false, Option::BOOLEAN, 0, 0, "ssl",
            "use SSL"},
#endif
        {"local", "false", false, Option::BOOLEAN, 0, 0, "local",
            "Use local connection mechanism"},
        {"user", "", false, Option::STRING, 0, 0, "user",
            "Specifies user name"},

        {"password", "", false, Option::STRING, 0, 0, "password",
            "Specifies password"}

    };
    const Uint32 NUM_OPTIONS = sizeof(optionsTable) / sizeof(optionsTable[0]);

    om.registerOptions(optionsTable, NUM_OPTIONS);

#if defined (PEGASUS_OS_VMS)
    String configFile = "cimserver.conf";
#else
    String configFile = pegasusHome + "/cimserver.conf";
#endif

    cout << "Config file from " << configFile << endl;

    if (FileSystem::exists(configFile))
        om.mergeFile(configFile);

    om.mergeCommandLine(argc, argv);

    om.checkRequiredOptions();
}
void GetOptions(
    OptionManager& om,
    int& argc,
    char** argv,
    const String& testHome)
{
    static const char* outputFormats[] = { "xml", "mof", "txt"};
    static const Uint32 NUM_OUTPUTFORMATS = sizeof(outputFormats) /
                                            sizeof(outputFormats[0]);

    static struct OptionRow optionsTable[] =
        //optionname defaultvalue rqd  type domain domainsize clname hlpmsg
    {
    {"location", "localhost:5988", false, Option::STRING, 0, 0, "-n",
                                        "specifies system and port" },

    {"namespace", "root/cimv2", false, Option::STRING, 0, 0, "-n",
                                        "specifies namespace to use for operation" },

        //{"outputformats", "mof", false, Option::STRING, outputFormats,
        //                                 NUM_OUTPUTFORMATS, "o",
        //                                "Output in xml, mof, txt"},

        {"deepinheritance", "false", false, Option::BOOLEAN, 0, 0, "d",
                                        "If set does deep enum "},

        {"version", "false", false, Option::BOOLEAN, 0, 0, "v",
                                        "Displays software Version "},

        {"help", "false", false, Option::BOOLEAN, 0, 0, "h",
                            "Prints help message with command line options "},

        {"debug", "false", false, Option::BOOLEAN, 0, 0, "d",
                     "Not Used "},
    };
    const Uint32 NUM_OPTIONS = sizeof(optionsTable) / sizeof(optionsTable[0]);

    om.registerOptions(optionsTable, NUM_OPTIONS);

    //We want to make this code common to all of the commands

    String configFile = "/CLTest.conf";

    cout << "Config file from " << configFile << endl;

    if (FileSystem::exists(configFile))
             om.mergeFile(configFile);

    om.mergeCommandLine(argc, argv);

    om.checkRequiredOptions();

}