Repository navigation
Expand file tree
/
Copy pathCmdLineOptions.cpp
More file actions
executable file
·87 lines (69 loc) · 2.61 KB
/
Copy pathCmdLineOptions.cpp
File metadata and controls
executable file
·87 lines (69 loc) · 2.61 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// Created by mwo on 6/11/15.
//
#include "CmdLineOptions.h"
namespace xmreg
{
/**
* Take the acc and *avv[] from the main() and check and parse
* all the options given
*/
CmdLineOptions::CmdLineOptions(int acc, const char *avv[]) {
positional_options_description p;
options_description desc(
"loki-locker, Loki Locker backend service");
desc.add_options()
("help,h", value<bool>()->default_value(false)
->implicit_value(true),
"produce help message")
("testnet,t", value<bool>()->default_value(false)
->implicit_value(true),
"use testnet blockchain")
("stagenet,s", value<bool>()->default_value(false)
->implicit_value(true),
"use stagenet blockchain")
("do-not-relay", value<bool>()->default_value(false)
->implicit_value(true),
"does not relay txs to other nodes. useful "
"when testing construction and submiting txs")
("port,p", value<string>()->default_value("1984"),
"default port for restbed service of Loki Locker")
("config-file,c", value<string>()
->default_value("./config/config.json"),
"Config file path.")
("log-file,l", value<string>()
->default_value("./loki-locker.log"),
"Name and path to log file. -l \"\" to disable log file.");
store(command_line_parser(acc, avv)
.options(desc)
.positional(p)
.run(), vm);
notify(vm);
if (vm.count("help"))
{
if (vm["help"].as<bool>())
cout << desc << "\n";
}
}
/**
* Return the value of the argument passed to the program
* in wrapped around boost::optional
*/
template<typename T>
boost::optional<T>
CmdLineOptions::get_option(const string & opt_name) const
{
if (!vm.count(opt_name))
{
return boost::none;
}
return vm[opt_name].as<T>();
}
// explicit instantiations of get_option template function
template boost::optional<string>
CmdLineOptions::get_option<string>(const string & opt_name) const;
template boost::optional<bool>
CmdLineOptions::get_option<bool>(const string & opt_name) const;
template boost::optional<size_t>
CmdLineOptions::get_option<size_t>(const string & opt_name) const;
}