Fixed command line options

This commit is contained in:
zvon 2019-01-09 22:19:47 +01:00
parent 1aa3f6b05f
commit 55efe036dd

View File

@ -51,7 +51,7 @@ void parseSeasonNumbers(std::set<int> &seasons_num, const char *argument) {
}
}
bool parseCommandLine(std::string &show, std::set<int> &seasons_num, std::string &path, bool &change_dir, int argc, char **argv) {
int parseCommandLine(std::string &show, std::set<int> &seasons_num, std::string &path, bool &change_dir, int argc, char **argv) {
static struct option long_options[] = {
{"show", required_argument, 0, 's' },
{"season", required_argument, 0, 'n' },
@ -60,9 +60,8 @@ bool parseCommandLine(std::string &show, std::set<int> &seasons_num, std::string
{"trust", no_argument, 0, 't' },
{"linux", no_argument, 0, 'x' },
{"lang", required_argument, 0, 'l' },
{"print-langs", no_argument, 0, 0 },
{"help", no_argument, 0, 'h' },
{0, 0, 0, 0 }
{"print-langs", no_argument, 0, '0' },
{"help", no_argument, 0, 'h' }
};
while(1) {
@ -97,21 +96,21 @@ bool parseCommandLine(std::string &show, std::set<int> &seasons_num, std::string
} else {
std::cerr << "Invalid language choice" << std::endl;
printLangs();
return false;
return -1;
}
break;
case '0':
printLangs();
return true;
return 1;
case 'h':
printHelp();
return true;
return 1;
default:
return false;
return -1;
}
}
return true;
return 0;
}
int main(int argc, char** argv) {
@ -120,8 +119,13 @@ int main(int argc, char** argv) {
std::string path{"."};
bool change_dir{true};
if( !parseCommandLine(show, seasons_num, path, change_dir, argc, argv) )
{
auto tmp = parseCommandLine(show, seasons_num, path, change_dir, argc, argv);
if( tmp == -1 )
return 1;
else if ( tmp == 1 )
return 0;
}
if( !FSLib::isDirectory(path) )
change_dir = true;