]> git.localhorst.tv Git - l2e.git/blob - src/app/Arguments.cpp
fixed flags in makefiles
[l2e.git] / src / app / Arguments.cpp
1 /*
2  * Arguments.cpp
3  *
4  *  Created on: Sep 15, 2012
5  *      Author: holy
6  */
7
8 #include "Arguments.h"
9
10 #include <stdexcept>
11 #include <string>
12
13 namespace app {
14
15 Arguments::Arguments()
16 : outfile(0)
17 , runlevel(PLAY) {
18
19 }
20
21
22 void Arguments::Read(int argc, char **argv) {
23         for (int i(1); i < argc; ++i) {
24                 char *arg(argv[i]);
25                 if (arg[0] == '-') {
26                         switch (arg[1]) {
27                                 case 'd':
28                                         runlevel = DUMP;
29                                         break;
30                                 case 'o':
31                                         if (i + 1 >= argc) {
32                                                 throw std::runtime_error("missing argument to -o");
33                                         }
34                                         ++i;
35                                         outfile = argv[i];
36                                         runlevel = WRITE;
37                                         break;
38                                 case 'B':
39                                         runlevel = BATTLE;
40                                         break;
41                                 case 'M':
42                                         runlevel = MAP;
43                                         break;
44                                 case 'S':
45                                         runlevel = SOURCE_WIKI;
46                                         break;
47                                 default:
48                                         throw std::runtime_error(std::string("unknown option ") + arg[1]);
49                                         break;
50                         }
51                 } else {
52                         infiles.push_back(arg);
53                 }
54         }
55 }
56
57 }