From 6584a6f0e4f68bce9b2dc0725bb124c57962c7b6 Mon Sep 17 00:00:00 2001 From: Heaven Date: Thu, 7 May 2026 15:32:06 +0200 Subject: [PATCH] Added "version", "help" and "clean" args. --- src/Output.cpp | 26 ++++++++++++++++++++++++-- src/Output.hpp | 2 ++ src/main.cpp | 23 ++++++++++++++++++++--- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/Output.cpp b/src/Output.cpp index 240d7a3..c13cb32 100644 --- a/src/Output.cpp +++ b/src/Output.cpp @@ -1,7 +1,11 @@ #include "Output.hpp" +#include +#include + #include "fmt/base.h" #include "fmt/color.h" +#include namespace Output { void printMenu() { @@ -22,14 +26,32 @@ namespace Output { fmt::print(fmt::fg(fmt::color::light_coral), " install Run cmake --install. Needs admin privileges.\n" ); - fmt::print(fmt::fg(fmt::color::light_coral), + fmt::print(fmt::fg(fmt::color::light_green), " clean Clean the build directory.\n" ); - fmt::print(fmt::fg(fmt::color::light_coral), + fmt::print(fmt::fg(fmt::color::light_green), " help Show help.\n" ); fmt::print(fmt::fg(fmt::color::light_green), " version Current cmkr version.\n" ); } + + void printArgClean() { + std::filesystem::path dirPath = "build"; + + if (!std::filesystem::exists(dirPath) || !std::filesystem::is_directory(dirPath)) return; + + for (const auto& entry : std::filesystem::directory_iterator(dirPath)) { + std::filesystem::remove_all(entry.path()); + } + + fmt::print(fmt::fg(fmt::color::light_green), + "[Lazymake] Cleaned up build directory!\n" + ); + } + + void printArgVersion() { + fmt::print("Version: 0.0.1 (Early pre-pre-pre-pre alpha\n"); + } } diff --git a/src/Output.hpp b/src/Output.hpp index b48ada6..ff0198b 100644 --- a/src/Output.hpp +++ b/src/Output.hpp @@ -2,4 +2,6 @@ namespace Output { void printMenu(); + void printArgClean(); + void printArgVersion(); } diff --git a/src/main.cpp b/src/main.cpp index ba02972..97f6609 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,12 +1,29 @@ +#include + #include "Output.hpp" -// #include -// #include +#include "fmt/base.h" int main(int argc, char* argv[]) { // fmt::print("Amount of args: {}\n", argc); + // for (int i = 0; i < argc; i++) { // fmt::print("argv{}: {}\n", i, argv[i]); // } - Output::printMenu(); + if (argc == 1) { + Output::printMenu(); + return 0; + } + + if (std::string_view(argv[1]) == "clean") { + Output::printArgClean(); + } + + if (std::string_view(argv[1]) == "help") { + Output::printMenu(); + } + + if (std::string_view(argv[1]) == "version") { + Output::printArgVersion(); + } }