Add options support

master
Estelle Poulin 5 years ago
parent c94aca0373
commit 7f58dc9d70

@ -3,6 +3,7 @@
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
int opt; int opt;
printf("Options:");
while ((opt = getopt(argc, argv, "-1246ab:c:e:fgi:kl:m:no:p:qstvx" while ((opt = getopt(argc, argv, "-1246ab:c:e:fgi:kl:m:no:p:qstvx"
"AB:CD:E:F:GI:J:KL:MNO:PQ:R:S:TVw:W:XYy")) != -1) { "AB:CD:E:F:GI:J:KL:MNO:PQ:R:S:TVw:W:XYy")) != -1) {
// Stop processing options after the first positional argument and set // Stop processing options after the first positional argument and set
@ -11,7 +12,13 @@ main(int argc, char *argv[]) {
optind -= 1; optind -= 1;
break; break;
} }
printf(" -%c", opt);
if (optarg != 0) {
printf(" %s", optarg);
}
} }
printf("\n");
if (optind >= argc) { if (optind >= argc) {
fprintf(stderr, "No destination found.\n"); fprintf(stderr, "No destination found.\n");

Loading…
Cancel
Save