]> git.sesse.net Git - nageru/blob - flags.cpp
Add a command-line option to change themes.
[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                 { "theme", required_argument, 0, 't' },
14                 { "va-display", required_argument, 0, 1000 },
15                 { "http-uncompressed-video", no_argument, 0, 1001 },
16                 { 0, 0, 0, 0 }
17         };
18         for ( ;; ) {
19                 int option_index = 0;
20                 int c = getopt_long(argc, argv, "c:t:", long_options, &option_index);
21
22                 if (c == -1) {
23                         break;
24                 }
25                 switch (c) {
26                 case 'c':
27                         global_flags.num_cards = atoi(optarg);
28                         break;
29                 case 't':
30                         global_flags.theme_filename = optarg;
31                         break;
32                 case 1000:
33                         global_flags.va_display = optarg;
34                         break;
35                 case 1001:
36                         global_flags.uncompressed_video_to_http = true;
37                         break;
38                 default:
39                         fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
40                         exit(1);
41                 }
42         }
43 }