forked from tjjh89017/ezio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.cpp
35 lines (30 loc) · 1.32 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
#include "config.hpp"
void config::parse_from_argv(int argc, char **argv)
{
bpo::options_description desc("Allowed Options");
desc.add_options()
("help,h", "some help")
("ratio,e", bpo::value<int>(&seed_limit_ezio), "assign seeding ratio limit")
("timeout,t", bpo::value<int>(&timeout_ezio), "assign timeout as N min(s).")
("contact,k",bpo::value<int>(&max_contact_tracker_times), "assign maxminum failure number to contact tracker")
("maxu,m", bpo::value<int>(&max_upload_ezio), "assign maxminum upload number")
("maxc,c", bpo::value<int>(&max_connection_ezio), "assign maxminum connection number")
("sequential,s", bpo::bool_switch(&sequential_flag)->default_value(false), "enable sequential download")
("file,f", bpo::bool_switch(&file_flag)->default_value(false), "read data from file rather than raw disk")
("upload,U", bpo::bool_switch(&seed_flag)->default_value(false), "seed mode")
("torrent", bpo::value<std::string>(&torrent), "")
("save_path", bpo::value<std::string>(&save_path), "");
bpo::positional_options_description pos_opt;
pos_opt.add("torrent", 1).add("save_path", 1);
bpo::variables_map vmap;
bpo::store(bpo::command_line_parser(argc, argv)
.options(desc)
.positional(pos_opt)
.run(),
vmap);
bpo::notify(vmap);
if(vmap.count("help")){
std::cout << desc << std::endl;
exit(0);
}
}