summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-02 13:37:53 -0500
committerbd <bdunahu@operationnull.com>2025-03-02 13:37:53 -0500
commita9af4fd3243e470ff33d50968f998bf78c152717 (patch)
treeb9815d43d79b631939cd531512b470829ba16436 /src/main.cc
parenta81e74ecfc73e27cceba863b8c780ebde51a8d47 (diff)
Added logger class, tests, arg parsing and cleanup
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc56
1 files changed, 56 insertions, 0 deletions
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 <getopt.h>
+#include <iostream>
+
+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;
+}