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();


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

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

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

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

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

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

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

} else if (strncmp(argv[1], "news", strlen(argv[1])) == 0) {
argv[1][0] = '\0';
} else if (isSame(argv, "news")) {
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';
return unterOption_update(&settings, argc, argv);

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

} 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;
}
}
@ -1425,3 +1417,12 @@ void unterOption_RemoveSettings_or_CacheDire_help(std::string programName)
<< " -h, --help" << 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",
languages = "GerDub,GerSub,Eng,",
genaueHoster = "",
version = "3.7.0",
version = "3.7.1",
defaultFileVersion="1.6",
outputFilePath = "",
default_checkPath = "",
@ -110,6 +110,7 @@ struct Settings {
int manageParameter(Settings &settings, int argc, char ** argv);
int loadDefaulOptions(Settings & settings);
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);

int setPaths(Settings &settings);