-
Notifications
You must be signed in to change notification settings - Fork 21
/
config.cpp
38 lines (32 loc) · 872 Bytes
/
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
#include "config.hpp"
namespace ezio
{
void config::parse_from_argv(int argc, char **argv)
{
// clang-format off
bpo::options_description desc("Allowed Options");
desc.add_options()
("help,h", "some help")
("file,F", bpo::bool_switch(&file_flag)->default_value(false), "read data from file rather than raw disk")
("listen,l", bpo::value<std::string>(&listen_address), "gRPC service listen address and port, default is 127.0.0.1:50051")
("version,v", "show version")
;
// clang-format on
// clang-format off
bpo::variables_map vmap;
bpo::store(bpo::command_line_parser(argc, argv)
.options(desc)
.run(),
vmap);
bpo::notify(vmap);
// clang-format on
if (vmap.count("help")) {
std::cout << desc << std::endl;
exit(0);
}
if (vmap.count("version")) {
std::cout << "ezio " << GIT_VERSION << std::endl;
exit(0);
}
}
} // namespace ezio