summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-03-11 11:28:25 -0400
committerGitHub <noreply@github.com>2025-03-11 11:28:25 -0400
commit33c7c78b1c65c375d0291fd435e02ddc9d35681b (patch)
tree25646d98b4bfcf4b9a664eabfc2651c481984c1d /src/main.cc
parent66edce63597093cf5f3afa5b577fd9e3ecae0ef6 (diff)
parent202f9a05d449ddc1160584c4e8a87f397f248e94 (diff)
Merge pull request #23 from bdunahu/bdunahu
Memory simulator CLI function implementation
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc51
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
+}