-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUtils.cpp
50 lines (48 loc) · 1.25 KB
/
Utils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <getopt.h>
#include "Utils.h"
std::string Options::players = "";
int Options::num_decks = 6;
int Options::num_rounds = 1;
size_t Options::deck_seed = 0;
bool Options::verbose_flag = false;
void Options::getOptions(int argc, char* argv[]) {
int option_index = 0;
option long_opts[] = {
{ "verbose", no_argument, nullptr, 'v' },
{ "help", no_argument, nullptr, 'h' },
{ "decks", required_argument, nullptr, 'd' },
{ "rounds", required_argument, nullptr, 'r' },
{ "seed", required_argument, nullptr, 's' },
{ "players", required_argument, nullptr, 'p' },
{ nullptr, 0, nullptr, '\0' },
};
int opt;
while ((opt = getopt_long(argc, argv, "hvd:r:s:p:", long_opts, &option_index)) != -1) {
switch (opt) {
case 'v':
verbose_flag = true;
break;
case 'h':
ERROR("Not ready yet :(");
break;
case 'd':
num_decks = atoi(optarg);
break;
case 'r':
num_rounds = atoi(optarg);
break;
case 's':
deck_seed = atoi(optarg);
if(deck_seed == 0) {
ERROR("Invalid deck seed");
}
break;
case 'p':
players = optarg;
break;
default:
ERROR("Invalid Argument");
break;
}
}
}