From 61d444527c5021f029eb65a88305474faac25fbd Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 12 Mar 2025 00:21:14 -0500 Subject: [PATCH] added more App functions --- src/App.cpp | 29 ++++++++++++++++++++++++++++- src/App.h | 8 +++++++- src/main.cpp | 2 +- src/pch.hpp | 2 ++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index d1df3ed..a65e2d8 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -2,7 +2,7 @@ App* App::instance = nullptr; -App::App() { +App::App(const int& argc, char* argv[]) { if(instance != nullptr) { std::cout << "App already exists\nThere can only be one!\n"; @@ -13,6 +13,8 @@ App::App() { instance = this; + handleArgs(argc, argv); + } App::~App() { @@ -29,3 +31,28 @@ void App::run() { } } +void App::load(std::string lib) { + +} + +void App::handleArgs(const int& argc, char* argv[]) { + + int i = 0; + + while(i < argc) { + if(strcmp(argv[i], "-h") == 0) { + printHelp(); + end(); + } else { + break; + } + i++; + } + + while(i < argc) { + + load(argv[i]); + + i++; + } +} diff --git a/src/App.h b/src/App.h index 0bafd9c..eaec908 100644 --- a/src/App.h +++ b/src/App.h @@ -15,13 +15,19 @@ class App { std::vector modules; public: - App(); + App(const int&, char*[]); ~App(); static App& Get() { return *instance; } void run(); + void load(std::string); + + void handleArgs(const int&, char*[]); + + void printHelp(); + void end() { done = true; }; }; diff --git a/src/main.cpp b/src/main.cpp index ae5d690..307cef6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,6 @@ #include "App.h" int main(int argc, char* argv[]) { - App app; + App app(argc, argv); app.run(); } diff --git a/src/pch.hpp b/src/pch.hpp index 9f8da4f..a15dcec 100644 --- a/src/pch.hpp +++ b/src/pch.hpp @@ -5,4 +5,6 @@ #include #include +#include + #endif