From 3895272a7f238c9aef0b584bd3b10b900445245d Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Tue, 15 Apr 2025 19:45:02 +0000
Subject: [PATCH] refactored

---
 cli/main.cpp |   25 ++++++-------------------
 1 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/cli/main.cpp b/cli/main.cpp
index a20c2bc..ca6c810 100644
--- a/cli/main.cpp
+++ b/cli/main.cpp
@@ -1,9 +1,10 @@
 #include <filesystem>
 #include <fstream>
+#include <iostream>
+#include <unordered_map>
 
-#include "Builtins/PrintModule.hpp"
-#include "Builtins/SleepModule.hpp"
-#include "ScriptInterpreter.hpp"
+#include "options.h"
+#include "VoidScript.hpp"
 
 const std::unordered_map<std::string, std::string> params = {
     { "--help",    "Print this help message"          },
@@ -55,22 +56,8 @@
 
     const std::string filename = std::filesystem::canonical(file).string();
 
-    try {
-        std::ifstream input(filename);
-        if (!input.is_open()) {
-            std::cerr << "Error: Could not open file " << filename << "\n";
-            return 1;
-        }
-
-        std::string       content((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
-        ScriptInterpreter interp;
-        interp.registerModule("print", std::make_shared<PrintFunction>());
-        interp.registerModule("sleep", std::make_shared<SleepFunction>());
-        interp.executeScript(content, filename, "DEFAULT", false);
-    } catch (const std::exception & e) {
-        std::cerr << "Parser error: " << e.what() << "\n";
-        return 1;
-    }
+    VoidScript voidscript(filename);
+    return voidscript.run();
 
     return 0;
 }

--
Gitblit v1.9.3