Progressing

This commit is contained in:
2026-05-12 17:01:50 +02:00
parent 0d1c096a73
commit cca309db3e
3 changed files with 56 additions and 24 deletions

View File

@@ -9,7 +9,22 @@
#include <cstdio> #include <cstdio>
#include <system_error> #include <system_error>
namespace {
std::filesystem::path buildDir = "build";
std::error_code errorCode;
}
namespace Output { namespace Output {
bool checkValidBuildDir() {
if (!std::filesystem::exists(buildDir, errorCode) || !std::filesystem::is_directory(buildDir, errorCode)) {
fmt::print(fmt::fg(fmt::color::light_coral),
"[Lazymake] Cleanup failed. Nothing to clean :(\n"
);
return false;
}
return true;
}
void printMenu() { void printMenu() {
fmt::print("Usage: lmake [arguments]\n"); fmt::print("Usage: lmake [arguments]\n");
fmt::print("arguments:\n"); fmt::print("arguments:\n");
@@ -22,7 +37,7 @@ namespace Output {
fmt::print(fmt::fg(fmt::color::light_green), fmt::print(fmt::fg(fmt::color::light_green),
" build <extra cmake args> Run cmake and build.\n" " build <extra cmake args> Run cmake and build.\n"
); );
fmt::print(fmt::fg(fmt::color::light_coral), fmt::print(fmt::fg(fmt::color::light_golden_rod_yellow),
" run <optional args> Run build.\n" " run <optional args> Run build.\n"
); );
fmt::print(fmt::fg(fmt::color::light_coral), fmt::print(fmt::fg(fmt::color::light_coral),
@@ -40,17 +55,18 @@ namespace Output {
} }
void printArgClean() { void printArgClean() {
std::filesystem::path dirPath = "build"; // std::filesystem::path dirPath = "build";
std::error_code errorCode; // std::error_code errorCode;
if (!std::filesystem::exists(dirPath, errorCode) || !std::filesystem::is_directory(dirPath, errorCode)) { // if (!std::filesystem::exists(buildDir, errorCode) || !std::filesystem::is_directory(buildDir, errorCode)) {
fmt::print(fmt::fg(fmt::color::light_coral), // fmt::print(fmt::fg(fmt::color::light_coral),
"[Lazymake] Cleanup failed. Nothing to clean :(\n" // "[Lazymake] Cleanup failed. Nothing to clean :(\n"
); // );
return; // return;
} // }
std::filesystem::remove_all(dirPath, errorCode); if (checkValidBuildDir()) {
std::filesystem::remove_all(buildDir, errorCode);
// for (const auto& entry : std::filesystem::directory_iterator(dirPath)) { // for (const auto& entry : std::filesystem::directory_iterator(dirPath)) {
// std::filesystem::remove_all(entry.path()); // std::filesystem::remove_all(entry.path());
@@ -63,12 +79,13 @@ namespace Output {
return; return;
} }
std::filesystem::create_directory(dirPath, errorCode); std::filesystem::create_directory(buildDir, errorCode);
fmt::print(fmt::fg(fmt::color::light_green), fmt::print(fmt::fg(fmt::color::light_green),
"[Lazymake] Cleaned up build directory :D\n" "[Lazymake] Cleaned up build directory :D\n"
); );
} }
}
void printArgVersion() { void printArgVersion() {
fmt::print("Version: 0.0.1 (Early pre-pre-pre-pre alpha\n"); fmt::print("Version: 0.0.1 (Early pre-pre-pre-pre alpha\n");
@@ -106,4 +123,12 @@ namespace Output {
); );
return status; return status;
} }
void runBuild() {
if (checkValidBuildDir()) {
fmt::print("FOUND BUILD FOLDER\n");
std::system("./build/lmake");
fmt::print("333FOUND BUILD FOLDER2\n");
}
}
} }

View File

@@ -3,9 +3,12 @@
#include <string> #include <string>
namespace Output { namespace Output {
bool checkValidBuildDir();
void printMenu(); void printMenu();
void printArgClean(); void printArgClean();
void printArgVersion(); void printArgVersion();
int executeCommand(const std::string& command, const std::string& successMsg); int executeCommand(const std::string& command, const std::string& successMsg);
void runBuild();
} }

View File

@@ -29,6 +29,10 @@ int main(int argc, char* argv[]) {
Output::executeCommand("cmkr build", "Cmake build completed :D"); Output::executeCommand("cmkr build", "Cmake build completed :D");
} }
if (std::string_view(argv[1]) == "run") {
Output::runBuild();
}
if (std::string_view(argv[1]) == "clean") { if (std::string_view(argv[1]) == "clean") {
Output::printArgClean(); Output::printArgClean();
} }