-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.cpp
48 lines (38 loc) · 1.27 KB
/
config.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
#include "config.h"
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <iostream>
namespace po = boost::program_options;
namespace fs = boost::filesystem;
using std::cout;
using std::endl;
void Config::ParseOptions(int argc, char* argv[]) {
/* Options description */
po::options_description optional_desc("Optional options");
optional_desc.add_options()
("help,h", "produce help message")
("output_file,o", po::value<std::string>(&OutputFile)->default_value("agr.txt"), "output file")
("jobs,j", po::value<unsigned>(&JobsNum)->default_value(-1), "threads number")
;
po::options_description required_desc("Required options");
required_desc.add_options()
("path,p", po::value<std::string>(&Directory)->required(), "directory with logs")
("count,c", po::value<unsigned>(&FilesNum)->required(), "logs number")
;
po::options_description all_desc("Options");
all_desc.add(optional_desc).add(required_desc);
/* Parse */
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, all_desc), vm);
if (vm.count("help")) {
cout << all_desc << endl;
exit(0);
}
try {
po::notify(vm);
} catch (po::error& e) {
cout << e.what() << endl;
cout << all_desc << endl;
exit(0);
}
}