From a9af4fd3243e470ff33d50968f998bf78c152717 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 2 Mar 2025 13:37:53 -0500 Subject: Added logger class, tests, arg parsing and cleanup --- src/main.cc | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main.cc (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..6871fb9 --- /dev/null +++ b/src/main.cc @@ -0,0 +1,56 @@ +#include "logger.h" +#include +#include + +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" + << std::endl; +} + +void parseArguments(int argc, char **argv, Logger &logger, bool &python) +{ + struct option long_options[] = { + {"debug", no_argument, 0, 'd'}, + {"no-python", no_argument, 0, 'p'}, + {0, 0, 0, 0}}; + + python = true; + + int opt; + + 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."); + break; + case 'p': + logger.log(INFO, "Python will NOT be started!"); + python = false; + break; + default: + err(); + exit(EXIT_FAILURE); + } + } +} + +int main(int argc, char **argv) +{ + + Logger logger("vector.log"); + logger.log(INFO, "Initializing..."); + + bool python = true; + parseArguments(argc, argv, logger, python); + + if (python) { + // fork off python here + ; + logger.log(INFO, "Python started."); + } + + return EXIT_SUCCESS; +} -- cgit v1.2.3