forked from markus/S_New4
better helpmenue for clean && show possible subfunction with invlaid subfunctioninput
This commit is contained in:
parent
3080d4102d
commit
67d9d8c832
@ -39,14 +39,21 @@ int manageParameter(Settings &settings, int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int res = compare("--help\ndefault\nurl\n--version\nsearch\ninfo\nclean", argv[1]);
|
||||
if(res != 1) {
|
||||
std::cout << " => Error: " << ( (res == 0) ? std::string("Unbekannte Unteroption: '") + argv[1] + "'" :
|
||||
std::string("Mehrere Optionen für '") + argv[1] + std::string("' gefunden.") ) << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName() << " [Unteroption] [PARAMETER]" << std::endl;
|
||||
std::cout << "„" << getProgramName() << " --help“ liefert weitere Informationen." << std::endl;
|
||||
return 2;
|
||||
std::vector<std::string> res = compare("--help\ndefault\nurl\n--version\nsearch\ninfo\nclean", argv[1]);
|
||||
if(res.size() != 1) {
|
||||
if(res.size() == 0)
|
||||
std::cout << " => Error: Keine Unteroption für " << argv[1] << " gefunden." << std::endl;
|
||||
else if(res.size() > 1) {
|
||||
std::cout << " => Error: Mehrere Unteroptionen für '" << argv[1] << "' gefunden:" << std::endl;
|
||||
for (auto &e : res)
|
||||
std::cout << " > '" << argv[1] << "' =? " << e << std::endl;
|
||||
}
|
||||
std::cout << "Aufruf: " << getProgramName() << " [Unteroption] [PARAMETER]" << std::endl;
|
||||
std::cout << "„" << getProgramName() << " --help“ liefert weitere Informationen." << std::endl;
|
||||
return 2;
|
||||
}
|
||||
res.clear();
|
||||
|
||||
|
||||
if(strncmp(argv[1], "--help", strlen(argv[1])) == 0) {
|
||||
argv[1][0] = '\0';
|
||||
@ -242,9 +249,6 @@ int loadDefaulOptions(Settings &settings)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ifs.close();
|
||||
return 0;
|
||||
}
|
||||
@ -889,8 +893,8 @@ void unterOption_clean(Settings * settings, int argc, char **argv)
|
||||
{
|
||||
if(argc > 2)
|
||||
if(strncmp("--help", argv[2], strlen(argv[2])) == 0) {
|
||||
std::cout << "Aufruf: " << getProgramName() << " clean" << std::endl << std::endl;
|
||||
std::cout << "Mit dieser Function werden die Cookie-Files gelöscht." << std::endl;
|
||||
std::cout << "Aufruf: " << getProgramName() << "clean\n " << getProgramName() << "clean --help" << std::endl << std::endl
|
||||
<< "Beschreibung:" << std::endl << " Mit dieser Unterfunction kann man die Cookie-Dateien löschen." << std::endl << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -921,14 +925,15 @@ void unterOption_clean(Settings * settings, int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
int 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)
|
||||
{
|
||||
std::istringstream iStrStream( All_Options_with_komma_between + "\n");
|
||||
std::string line;
|
||||
int allFounds = 0;
|
||||
std::vector<std::string> allFounds;
|
||||
|
||||
while (getline(iStrStream, line).good())
|
||||
if(strncmp(line.c_str(), input.c_str(), input.length()) == 0) {
|
||||
allFounds++;
|
||||
allFounds.push_back(line);
|
||||
//std::cout << "Unteroption '" << input << "' stimmt mit '" << line << "' überein." << std::endl;
|
||||
}
|
||||
return allFounds;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <fstream>
|
||||
#include <limits.h> // PATH_MAX
|
||||
#include <unistd.h> // readlink()
|
||||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@ -61,7 +62,7 @@ struct Settings {
|
||||
|
||||
int manageParameter(Settings &settings, int argc, char ** argv);
|
||||
int loadDefaulOptions(Settings & settings);
|
||||
int 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);
|
||||
|
||||
std::string getProgramName();
|
||||
std::string getexepath();
|
||||
|
Loading…
Reference in New Issue
Block a user