1 #include "Configuration.h"
3 namespace remote
{ namespace diku_mch
{
5 void Configuration::printHelp(po::options_description
& desc
)
7 std::cerr
<< PACKAGE_NAME
<< " (MCH) version " << PACKAGE_VERSION
8 << std::endl
<< std::endl
14 void Configuration::read(int argc
, char **argv
)
16 // command line options
17 po::options_description
cmdline_options("Command line options");
19 cmdline_options
.add_options()
20 ("help", "Print usage help and exit")
21 ("config-help", "Print config file usage help and exit")
23 po::value
<std::string
>()->default_value("/etc/diku_mch.cfg"),
24 "Path to the configuration file.")
26 po::value
<int>()->default_value(false),
29 // declare all configuration groups
30 po::options_description
config("Configuration options");
34 po::value
<std::string
>()->default_value("/dev/remote"),
35 "Path to the remote mote device hierarchy.")
37 po::value
<std::string
>()->default_value("/var/run/motehost.events"),
38 "Path to the fifo notifying the motehost of mote hotplug events.")
40 po::value
<std::string
>()->default_value("localhost"),
41 "DNS or IP address of the mote server.")
43 po::value
<uint16_t>()->default_value(10001),
44 "Port number to use for connecting to the mote server.")
45 ("serverConnectionRetryInterval",
46 po::value
<uint64_t>()->default_value(30),
47 "Number of seconds to wait between server connection retries.")
51 store(po::parse_command_line(argc
, argv
, cmdline_options
), vm
);
52 } catch (boost::program_options::error exception
) {
53 std::cerr
<< "Error while parsing command line options: "
54 << exception
.what() << std::endl
<< std::endl
;
55 printHelp(cmdline_options
);
60 printHelp(cmdline_options
);
61 if (vm
.count("config-help"))
64 // get the configuration settings from a file
65 std::ifstream
ifs(Configuration::vm
["config-file"].as
<std::string
>().c_str());
67 store(parse_config_file(ifs
, config
), vm
);
68 } catch (boost::program_options::error exception
) {
69 std::cerr
<< "Error while parsing configuration file: "
70 << exception
.what() << std::endl
<< std::endl
;