diff --git a/FlippR-Driver/cli/main.cpp b/FlippR-Driver/cli/main.cpp index 3749c3c..9dbb68f 100644 --- a/FlippR-Driver/cli/main.cpp +++ b/FlippR-Driver/cli/main.cpp @@ -1,6 +1,8 @@ // // Created by rhetenor on 13.09.18. // +#include + #include #include #include @@ -16,22 +18,19 @@ using namespace flippR_driver; void siginthandler(int param) { 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: " << argv[0] << " "; - exit(1); - } + std::cout << "Usage: " << name << " [-ipc= -imc=] " + << "[-opc= -odc= -olc=] " + << "-osolc= -osc=]"; - 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 matrix_config; try @@ -42,14 +41,27 @@ int main (int argc, char *argv[]) catch(const std::exception& e) { std::cout << e.what(); - exit(2); + exit(EXIT_FAILURE); } std::shared_ptr 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);