working on cli

This commit is contained in:
Jonas Zeunert
2018-12-20 01:02:50 +01:00
parent 120d3693f2
commit 4a580537a2

View File

@@ -1,6 +1,8 @@
// //
// Created by rhetenor on 13.09.18. // Created by rhetenor on 13.09.18.
// //
#include <boost/program_options.hpp>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <memory> #include <memory>
@@ -16,22 +18,19 @@ using namespace flippR_driver;
void siginthandler(int param) void siginthandler(int param)
{ {
printf("Caught SIGINT... aborting!\n"); printf("Caught SIGINT... aborting!\n");
exit(1); exit(EXIT_SUCCESS);
} }
int main (int argc, char *argv[]) static void show_usage(const std::string &name)
{ {
if(argc != 3) std::cout << "Usage: " << name << " [-ipc=<input_pin_config_file> -imc=<input_matrix_config_file>] "
{ << "[-opc=<output_pin_config_file> -odc=<output_display_config_file> -olc=<output_lamp_config_file>] "
std::cout << "Usage: " << argv[0] << " <input_config_file> <matrix_config_file>"; << "-osolc=<output_solenoid_config_file> -osc=<output_sound_config_file>]";
exit(1);
}
signal(SIGINT, siginthandler); }
std::string input_config_file = argv[1];
std::string matrix_config_file = argv[2];
PrintHandler* start_print_handler(const std::string &input_config_file, const std::string &matrix_config_file)
{
std::ifstream input_config; std::ifstream input_config;
std::ifstream matrix_config; std::ifstream matrix_config;
try try
@@ -42,14 +41,27 @@ int main (int argc, char *argv[])
catch(const std::exception& e) catch(const std::exception& e)
{ {
std::cout << e.what(); std::cout << e.what();
exit(2); exit(EXIT_FAILURE);
} }
std::shared_ptr<input::InputDriver> driver = flippR_driver::get_InputDriver(input_config, matrix_config); std::shared_ptr<input::InputDriver> driver = flippR_driver::get_InputDriver(input_config, matrix_config);
PrintHandler* print_handler = new PrintHandler(driver); return new PrintHandler(driver);
}
// driver->register_event_handler(print_handler); //registriert sich eigentlich von selbst! int main (int argc, char *argv[])
{
if(argc < 3)
{
show_usage(argv[0]);
exit(EXIT_FAILURE);
}
// registering sigint
signal(SIGINT, siginthandler);
std::string input_config_file = argv[1];
std::string matrix_config_file = argv[2];
while(1); while(1);