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