diff options
author | bd <bdunahu@operationnull.com> | 2025-03-24 12:17:41 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-03-24 12:17:41 -0400 |
commit | 895b5ddd6fe4db906720ecbf0de0cab5acdb35ec (patch) | |
tree | 8d2d9df8054214d4c019ace03e33f74e6ba571d0 /gui/main.cc | |
parent | e05f5306f50029b0f5f471b70cfe45749d0d21f6 (diff) |
Added gui folder with its own CMake to house GUI+main.cc
Diffstat (limited to 'gui/main.cc')
-rw-r--r-- | gui/main.cc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/gui/main.cc b/gui/main.cc new file mode 100644 index 0000000..4c14fbe --- /dev/null +++ b/gui/main.cc @@ -0,0 +1,89 @@ +#include "cli.h" +#include "definitions.h" +#include "gui.h" +#include "logger.h" +#include <QApplication> +#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'; +} + +static void err() +{ + std::cerr << "Usage:\n\trisc_vector [OPTIONS]\nOptions:\n\t--debug,\t-d: " + "turn on verbose output\n\t--memory-only,\t-m: run the memory " + "simulator only, without a GUI.\n\t--version,\t-v: print the " + "version information and exit\n" + << std::endl; +} + +static void parseArguments(int argc, char **argv, bool &memory_only) +{ + struct option long_options[] = { + {"debug", no_argument, 0, 'd'}, + {"memory-only", no_argument, 0, 'm'}, + {0, 0, 0, 0}}; + + int opt; + + while ((opt = getopt_long(argc, argv, "d:m", long_options, NULL)) != -1) { + switch (opt) { + case 'd': + global_log->setLevel(DEBUG); + global_log->log(DEBUG, "DEBUG output enabled."); + break; + case 'm': + global_log->log(INFO, "Starting the storage CLI interface..."); + memory_only = true; + break; + default: + err(); + exit(EXIT_FAILURE); + } + } +} + +int main(int argc, char **argv) +{ + print_version_number(); + global_log->log(INFO, "Initializing..."); + + bool memory_only = false; + parseArguments(argc, argv, memory_only); + + if (memory_only) { + Cli cli; + cli.run(); + } else { + global_log->log(INFO, "Starting QT..."); + QApplication a(argc, argv); + Gui w; + w.show(); + a.exec(); + } + + global_log->log(INFO, "Cleaning up..."); + global_log->log(INFO, "Goodbye!"); + return EXIT_SUCCESS; +} |