diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-03-21 14:21:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-21 14:21:06 -0400 |
commit | b2dbd9fa44f57bfa7b67f828ed8b354f4af3a0b6 (patch) | |
tree | ffd8e0bd2b112180251804a096f601f745f9af1b /src/main.cc | |
parent | 1b01b557e76f8643964e5c367c072ab7778036f6 (diff) | |
parent | 5845ad71d78d310322046906ee4c8e91d007d57e (diff) |
Merge pull request #27 from bdunahu/bdunahu
Make memory simulator an optional command, switch to test fixtures
Changes look good
Diffstat (limited to 'src/main.cc')
-rw-r--r-- | src/main.cc | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/main.cc b/src/main.cc index 08b38e6..f5eecac 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ #include "cli.h" -#include "logger.h" #include "definitions.h" +#include "logger.h" #include <getopt.h> #include <iostream> @@ -22,36 +22,39 @@ static std::string banner = " _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ \n" " _/ _/ _/_/_/_/ _/_/_/ _/ _/_/ _/ _/ _/ \n" " _/_/ _/_/ "; -static void print_version_number() { std::cout << banner << version_number << '\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--no-python,\t-p: run without " - "GUI\n\t--version,\t-v: print the version information and exit\n" + "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 &python) +static void +parseArguments(int argc, char **argv, bool &memory_only) { struct option long_options[] = { {"debug", no_argument, 0, 'd'}, - {"no-python", no_argument, 0, 'p'}, + {"memory-only", no_argument, 0, 'm'}, {0, 0, 0, 0}}; - python = true; - int opt; - while ((opt = getopt_long(argc, argv, "d:p", long_options, NULL)) != -1) { + 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 'p': - global_log->log(INFO, "Python will NOT be started!"); - python = false; + case 'm': + global_log->log(INFO, "Starting the storage CLI interface..."); + memory_only = true; break; default: err(); @@ -63,20 +66,18 @@ static void parseArguments(int argc, char **argv, bool &python) int main(int argc, char **argv) { print_version_number(); - Cli cli; global_log->log(INFO, "Initializing..."); - bool python = true; - parseArguments(argc, argv, python); + bool memory_only = false; + parseArguments(argc, argv, memory_only); - if (python) { - // fork off python here - ; - global_log->log(INFO, "Python started."); + if (memory_only) { + Cli cli; + cli.run(); } - cli.run(); - + // fork off python here + global_log->log(INFO, "Python started."); global_log->log(INFO, "Cleaning up..."); global_log->log(INFO, "Goodbye!"); return EXIT_SUCCESS; |