From 86904d513734134beffc29c6f4012d53a99f25c5 Mon Sep 17 00:00:00 2001
From: Ferenc Szontágh <szf@fsociety.hu>
Date: Sun, 13 Apr 2025 15:38:34 +0000
Subject: [PATCH] some clean up, added function declaration

---
 cli/main.cpp |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/cli/main.cpp b/cli/main.cpp
index 882134c..1ec1928 100644
--- a/cli/main.cpp
+++ b/cli/main.cpp
@@ -2,6 +2,7 @@
 #include <fstream>
 
 #include "Builtins/PrintModule.hpp"
+#include "Builtins/SleepModule.hpp"
 #include "ScriptInterpreter.hpp"
 
 static bool DEBUG = false;
@@ -15,9 +16,20 @@
     std::string file;
     if (argc == 2) {
         file = argv[1];
-    } else if (argc == 3 && (std::string(argv[1]) == "-d" || std::string(argv[1]) == "--debug")) {
-        DEBUG = true;
-        file  = argv[2];
+    } else if (argc == 3) {
+        if (std::string(argv[1]) == "-d" || std::string(argv[1]) == "--debug") {
+            DEBUG = true;
+            file  = argv[2];
+        } else if (argv[1] == "-h" || argv[1] == "--help") {
+            std::cout << "Usage: " << argv[0] << " [-d / --debug] <script_file>\n";
+            return 0;
+        } else if (argv[1] == "-v" || argv[1] == "--vrsion") {
+            std::cout << "VoidScript v" << VERSION_STRING << "\n";
+            return 0;
+        } else {
+            std::cerr << "Usage: " << argv[0] << " [-d / --debug] <script_file>\n";
+            return 1;
+        }
     } else {
         std::cerr << "Usage: " << argv[0] << " [-d / --debug] <script_file>\n";
         return 1;
@@ -37,9 +49,10 @@
             return 1;
         }
 
-        std::string        content((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
+        std::string       content((std::istreambuf_iterator<char>(input)), std::istreambuf_iterator<char>());
         ScriptInterpreter interp;
-        interp.registerFunction("print", std::make_shared<PrintFunction>());
+        interp.registerModule("print", std::make_shared<PrintFunction>());
+        interp.registerModule("sleep", std::make_shared<SleepFunction>());
         interp.executeScript(content, filename, DEBUG);
     } catch (const std::exception & e) {
         std::cerr << "Parser error: " << e.what() << "\n";

--
Gitblit v1.9.3