|
2 | 2 | #include<stdlib.h> |
3 | 3 | #include<memory> |
4 | 4 | #include"app.h" |
5 | | - |
6 | | -std::vector<std::pair<std::string, std::string>>getoptions(int argc,char** argv) |
7 | | -{ |
8 | | - std::vector<std::pair<std::string, std::string>> ret{}; |
9 | | - |
10 | | - std::pair<std::string, std::string> pair{}; |
11 | | - |
12 | | -if (argc <=0) |
13 | | - { |
14 | | -return ret; |
15 | | - } |
16 | | - |
17 | | -for (int i =0; i < argc; i++) |
18 | | - { |
19 | | -// key found (must start with '-' (e.g. '-dbc')) |
20 | | -if (argv[i][0] =='-') |
21 | | - { |
22 | | - pair.first =std::string(argv[i]); |
23 | | - pair.second.clear(); |
24 | | - |
25 | | -if ((i +1) < argc && argv[i +1][0] !='-') |
26 | | - { |
27 | | -// key param |
28 | | - pair.second =std::string(argv[i +1]); |
29 | | -// unlooped i incremention |
30 | | - ++i; |
31 | | - } |
32 | | - |
33 | | - ret.push_back(pair); |
34 | | - } |
35 | | - } |
36 | | - |
37 | | -return ret; |
38 | | -} |
| 5 | +#include"options-parser.h" |
39 | 6 |
|
40 | 7 | intmain(int argc,char* argv[]) |
41 | 8 | { |
42 | | -auto opts =getoptions(argc, argv); |
| 9 | + OptionsParser parser; |
| 10 | +auto opts = parser.GetOptions(argc, argv); |
43 | 11 | auto app = std::make_unique<CoderApp>(opts); |
44 | 12 | app->Run(); |
45 | 13 | } |