Fixed command line options
This commit is contained in:
parent
1aa3f6b05f
commit
55efe036dd
@ -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[] = {
|
static struct option long_options[] = {
|
||||||
{"show", required_argument, 0, 's' },
|
{"show", required_argument, 0, 's' },
|
||||||
{"season", required_argument, 0, 'n' },
|
{"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' },
|
{"trust", no_argument, 0, 't' },
|
||||||
{"linux", no_argument, 0, 'x' },
|
{"linux", no_argument, 0, 'x' },
|
||||||
{"lang", required_argument, 0, 'l' },
|
{"lang", required_argument, 0, 'l' },
|
||||||
{"print-langs", no_argument, 0, 0 },
|
{"print-langs", no_argument, 0, '0' },
|
||||||
{"help", no_argument, 0, 'h' },
|
{"help", no_argument, 0, 'h' }
|
||||||
{0, 0, 0, 0 }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
@ -97,21 +96,21 @@ bool parseCommandLine(std::string &show, std::set<int> &seasons_num, std::string
|
|||||||
} else {
|
} else {
|
||||||
std::cerr << "Invalid language choice" << std::endl;
|
std::cerr << "Invalid language choice" << std::endl;
|
||||||
printLangs();
|
printLangs();
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
printLangs();
|
printLangs();
|
||||||
return true;
|
return 1;
|
||||||
case 'h':
|
case 'h':
|
||||||
printHelp();
|
printHelp();
|
||||||
return true;
|
return 1;
|
||||||
default:
|
default:
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
@ -120,8 +119,13 @@ int main(int argc, char** argv) {
|
|||||||
std::string path{"."};
|
std::string path{"."};
|
||||||
bool change_dir{true};
|
bool change_dir{true};
|
||||||
|
|
||||||
if( !parseCommandLine(show, seasons_num, path, change_dir, argc, argv) )
|
{
|
||||||
return 1;
|
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) )
|
if( !FSLib::isDirectory(path) )
|
||||||
change_dir = true;
|
change_dir = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user