added cmd error handling - thx zi0r

This commit is contained in:
tater 2018-07-14 17:03:50 -04:00
parent 8496e64dc5
commit 9d23e9654e

View File

@ -104,12 +104,10 @@ usage(void)
fprintf(stderr, " -c a|m color format ANSI or mirc. Default is ANSI\n");
fprintf(stderr, " -e u|a encode as unicode or ASCII. Default is unicode\n");
fprintf(stderr, " -i print font details.\n");
fprintf(stderr, " -h usage.\n");
fprintf(stderr, "\n");
exit(EX_USAGE);
printf("welp\n");
return;
}
opt_t opt;
@ -125,6 +123,10 @@ main(int argc, char *argv[])
opt.info = false;
opt.encoding = ENC_UNICODE;
if (argc < 2) {
usage();
}
while((o = getopt(argc, argv, "w:j:c:e:i")) != -1) {
switch (o) {
case 'w':
@ -143,7 +145,6 @@ main(int argc, char *argv[])
break;
default:
usage();
exit(EX_USAGE);
}
break;
case 'c':
@ -156,7 +157,6 @@ main(int argc, char *argv[])
break;
default:
usage();
exit(EX_USAGE);
}
break;
case 'e':
@ -169,15 +169,15 @@ main(int argc, char *argv[])
break;
default:
usage();
exit(EX_USAGE);
}
break;
case 'i':
opt.info = true;
break;
case 'h':
/* fallthrough */
default:
usage();
exit(EX_USAGE);
}
}