Rearange option parse loop

This commit is contained in:
Unknown 2019-02-17 10:12:59 +01:00
parent 6aa19317a3
commit 796f6146ab

View File

@ -124,16 +124,9 @@ int Mapper::start(int argc, char *argv[]) {
struct parg_state ps;
parg_init(&ps);
while (true) {
c = parg_getopt_long(&ps, argc, argv, "hi:o:", long_options, &option_index);
if (c == -1) {
if (input.empty() || output.empty()) {
std::cerr << "Input (world directory) or output (PNG filename) missing" << std::endl;
usage();
return 0;
}
break;
}
while ((c = parg_getopt_long(&ps, argc, argv, "hi:o:", long_options, &option_index)) != -1) {
switch (c) {
case '?':
if (option_index) {
@ -864,6 +857,12 @@ int Mapper::start(int argc, char *argv[]) {
return EXIT_FAILURE;
}
}
if (input.empty() || output.empty()) {
std::cerr << "Input (world directory) or output (PNG filename) missing" << std::endl;
usage();
return 0;
}
}
catch (std::runtime_error e) {
std::cout << "Command-line error: " << e.what() << std::endl;