diff options
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/src/main.cc b/src/main.cc index 68b3cdf..08b38e6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,18 +1,38 @@ -#include "logger.h" #include "cli.h" +#include "logger.h" +#include "definitions.h" #include <getopt.h> #include <iostream> +static Logger *global_log = Logger::getInstance(); +static std::string version_number = "v0.1"; +static std::string banner = + " _/_/_/ _/_/_/ _/_/_/ _/_/_/ \n" + " _/ _/ _/ _/ _/ \n" + " _/_/_/ _/ _/_/ _/ \n" + " _/ _/ _/ _/ _/ \n" + "_/ _/ _/_/_/ _/_/_/ _/_/_/ \n" + " \n" + " \n" + " _/_/ _/_/ \n" + " _/ _/ _/ _/_/_/_/ _/_/_/ _/_/_/_/_/ _/_/ _/_/_/ _/ \n" + " _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ \n" + "_/ _/ _/ _/_/_/ _/ _/ _/ _/ _/_/_/ _/ \n" + " _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ \n" + " _/ _/ _/_/_/_/ _/_/_/ _/ _/_/ _/ _/ _/ \n" + " _/_/ _/_/ "; +static void print_version_number() { std::cout << banner << version_number << '\n'; } -void err() +static void err() { std::cerr << "Usage:\n\trisc_vector [OPTIONS]\nOptions:\n\t--debug,\t-d: " - "turn on verbose output\n\t--no-python,\t-p: run without GUI\n" + "turn on verbose output\n\t--no-python,\t-p: run without " + "GUI\n\t--version,\t-v: print the version information and exit\n" << std::endl; } -void parseArguments(int argc, char **argv, Logger &logger, bool &python) +static void parseArguments(int argc, char **argv, bool &python) { struct option long_options[] = { {"debug", no_argument, 0, 'd'}, @@ -26,11 +46,11 @@ void parseArguments(int argc, char **argv, Logger &logger, bool &python) while ((opt = getopt_long(argc, argv, "d:p", long_options, NULL)) != -1) { switch (opt) { case 'd': - logger.setLevel(DEBUG); - logger.log(DEBUG, "DEBUG output enabled."); + global_log->setLevel(DEBUG); + global_log->log(DEBUG, "DEBUG output enabled."); break; case 'p': - logger.log(INFO, "Python will NOT be started!"); + global_log->log(INFO, "Python will NOT be started!"); python = false; break; default: @@ -42,19 +62,22 @@ void parseArguments(int argc, char **argv, Logger &logger, bool &python) int main(int argc, char **argv) { - Logger logger("vector.log"); - Cli cli; - logger.log(INFO, "Initializing..."); + print_version_number(); + Cli cli; + global_log->log(INFO, "Initializing..."); bool python = true; - parseArguments(argc, argv, logger, python); + parseArguments(argc, argv, python); if (python) { // fork off python here ; - logger.log(INFO, "Python started."); + global_log->log(INFO, "Python started."); } - cli.run(); + cli.run(); + + global_log->log(INFO, "Cleaning up..."); + global_log->log(INFO, "Goodbye!"); return EXIT_SUCCESS; -}
\ No newline at end of file +} |