added more App functions

This commit is contained in:
2025-03-12 00:21:14 -05:00
parent 6f706e7b69
commit 61d444527c
4 changed files with 38 additions and 3 deletions

View File

@@ -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++;
}
}

View File

@@ -15,13 +15,19 @@ class App {
std::vector<Module*> 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; };
};

View File

@@ -2,6 +2,6 @@
#include "App.h"
int main(int argc, char* argv[]) {
App app;
App app(argc, argv);
app.run();
}

View File

@@ -5,4 +5,6 @@
#include <cstring>
#include <vector>
#include <dlfcn.h>
#endif