changed server config parsing

This commit is contained in:
Jonas Zeunert
2019-07-30 23:31:47 +02:00
parent 8669335ba6
commit cbab0e1d5b
2 changed files with 10 additions and 1 deletions

View File

@@ -57,7 +57,7 @@ void FlippRServer::parse_server_config_file()
try try
{ {
config.open("./server_config.json"); config.open(this->server_config);
} }
catch(const std::exception e) catch(const std::exception e)
{ {
@@ -249,6 +249,12 @@ void FlippRServer::defineOptions(OptionSet& options)
.repeatable(false) .repeatable(false)
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::handle_config_file)) .callback(OptionCallback<FlippRServer>(this, &FlippRServer::handle_config_file))
.argument("display-config", true)); .argument("display-config", true));
options.addOption(Option("server-config", "-s", "Specify where the server-config file is located. Only needed when not in this folder.")
.required(this->display_config == "Not set")
.repeatable(false)
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::handle_config_file))
.argument("server-config", true));
} }
void FlippRServer::handle_config_file(const std::string &name, const std::string &value) void FlippRServer::handle_config_file(const std::string &name, const std::string &value)
@@ -269,6 +275,8 @@ void FlippRServer::handle_config_file(const std::string &name, const std::string
this->input_port = std::stoi(value); this->input_port = std::stoi(value);
else if(name == "output-port") else if(name == "output-port")
this->output_port = std::stoi(value); this->output_port = std::stoi(value);
else if(name == "server-config")
this->server_config = value;
else else
{ {
logger().information("Configuration \"" + name + "\" is not known."); logger().information("Configuration \"" + name + "\" is not known.");

View File

@@ -53,6 +53,7 @@ private:
std::string solenoid_config; std::string solenoid_config;
std::string sound_config; std::string sound_config;
std::string display_config; std::string display_config;
std::string server_config;
std::shared_ptr<input::InputDriver> input_driver; std::shared_ptr<input::InputDriver> input_driver;
std::shared_ptr<output::OutputDriver> output_driver; std::shared_ptr<output::OutputDriver> output_driver;