]> git.sesse.net Git - nageru/blob - flags.cpp
Re-run IWYU, again with lots of manual cleanup.
[nageru] / flags.cpp
1 #include "flags.h"
2
3 #include <getopt.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 Flags global_flags;
8
9 void parse_flags(int argc, char * const argv[])
10 {
11         static const option long_options[] = {
12                 { "num-cards", required_argument, 0, 'c' },
13                 { 0, 0, 0, 0 }
14         };
15         for ( ;; ) {
16                 int option_index = 0;
17                 int c = getopt_long(argc, argv, "c:", long_options, &option_index);
18
19                 if (c == -1) {
20                         break;
21                 }
22                 switch (c) {
23                 case 'c':
24                         global_flags.num_cards = atoi(optarg);
25                         break;
26                 default:
27                         fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
28                         exit(1);
29                 }
30         }
31 }