v3.7.1: verbessere unterfunktionentest: function isSame:

This commit is contained in:
Markus 2019-11-11 19:24:27 +01:00
parent 4237493dc2
commit 0414d3a8aa
2 changed files with 22 additions and 20 deletions

View File

@ -85,49 +85,41 @@ int manageParameter(Settings &settings, int argc, char **argv)
res.clear(); res.clear();




if((strncmp(argv[1], "--help", strlen(argv[1])) == 0) || (strncmp(argv[1], "help", strlen(argv[1])) == 0)) { if(isSame(argv, "--help") || isSame(argv, "help")) {
argv[1][0] = '\0';
return unterOption_help(settings); return unterOption_help(settings);


} else if (strncmp(argv[1], "default", strlen(argv[1])) == 0) { } else if (isSame(argv, "default")) {
argv[1][0] = '\0';
return unterOption_default(&settings, argc, argv); return unterOption_default(&settings, argc, argv);


} else if (strncmp(argv[1], "url", strlen(argv[1])) == 0) { } else if (isSame(argv, "url")) {
argv[1][0] = '\0';
return unterOption_url(&settings, argc, argv); return unterOption_url(&settings, argc, argv);


} else if (strncmp(argv[1], "--version", strlen(argv[1])) == 0) { } else if (isSame(argv, "--version")) {
unterOption_printVersion(settings); unterOption_printVersion(settings);
return -1; return -1;


} else if (strncmp(argv[1], "search", strlen(argv[1])) == 0) { } else if (isSame(argv, "search")) {
argv[1][0] = '\0';
return unterOption_search(&settings, argc, argv); return unterOption_search(&settings, argc, argv);


} else if (strncmp(argv[1], "info", strlen(argv[1])) == 0) { } else if (isSame(argv, "info")) {
argv[1][0] = '\0';
return unterOption_info(&settings, argc, argv); return unterOption_info(&settings, argc, argv);


} else if (strncmp(argv[1], "clean", strlen(argv[1])) == 0) { } else if (isSame(argv, "clean")) {
argv[1][0] = '\0';
unterOption_clean(&settings, argc, argv); unterOption_clean(&settings, argc, argv);
return -1; return -1;


} else if (strncmp(argv[1], "news", strlen(argv[1])) == 0) { } else if (isSame(argv, "news")) {
argv[1][0] = '\0';
return unterOption_news(&settings, argc, argv); return unterOption_news(&settings, argc, argv);


} else if (strncmp(argv[1], "--update", strlen(argv[1])) == 0) { } else if (isSame(argv, "--update")) {
argv[1][0] = '\0'; argv[1][0] = '\0';
return unterOption_update(&settings, argc, argv); return unterOption_update(&settings, argc, argv);


} else if (strncmp(argv[1], "--remove", strlen(argv[1])) == 0) { } else if (isSame(argv, "--remove")) {
argv[1][0] = '\0';
return unterOption_RemoveSettings_or_CacheDir(&settings, argc, argv); return unterOption_RemoveSettings_or_CacheDir(&settings, argc, argv);


} else { } else {
std::cout << " => Error: Invalid option " << argv[1] << ", but not detected in compare-Function" << std::endl; std::cout << " => Error: Invalid option '" << argv[1] << "', but not detected in compare-Function" << std::endl;
return 3; return 3;
} }
} }
@ -1425,3 +1417,12 @@ void unterOption_RemoveSettings_or_CacheDire_help(std::string programName)
<< " -h, --help" << std::endl << " -h, --help" << std::endl
<< " Mit dieser Option wird dieses Helpmenue ausgegeben." << std::endl; << " Mit dieser Option wird dieses Helpmenue ausgegeben." << std::endl;
} }

bool isSame(char **argv, std::string FunktionName)
{
if(strncmp(argv[1], FunktionName.c_str(), strlen(argv[1])) == 0) {
argv[1][0] = '\0';
return true;
}
return false;
}

View File

@ -81,7 +81,7 @@ struct Settings {
proxy_ip = "127.0.0.1", proxy_ip = "127.0.0.1",
languages = "GerDub,GerSub,Eng,", languages = "GerDub,GerSub,Eng,",
genaueHoster = "", genaueHoster = "",
version = "3.7.0", version = "3.7.1",
defaultFileVersion="1.6", defaultFileVersion="1.6",
outputFilePath = "", outputFilePath = "",
default_checkPath = "", default_checkPath = "",
@ -110,6 +110,7 @@ struct Settings {
int manageParameter(Settings &settings, int argc, char ** argv); int manageParameter(Settings &settings, int argc, char ** argv);
int loadDefaulOptions(Settings & settings); int loadDefaulOptions(Settings & settings);
std::vector<std::string> compare(std::string All_Options_with_komma_between, std::string input); std::vector<std::string> compare(std::string All_Options_with_komma_between, std::string input);
bool isSame(char ** argv, std::string FunktionName);
bool isNumber(std::string number); bool isNumber(std::string number);


int setPaths(Settings &settings); int setPaths(Settings &settings);