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 <system_error>
namespace {
std::filesystem::path buildDir = "build";
std::error_code errorCode;
}
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() {
fmt::print("Usage: lmake [arguments]\n");
fmt::print("arguments:\n");
@@ -22,7 +37,7 @@ namespace Output {
fmt::print(fmt::fg(fmt::color::light_green),
" 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"
);
fmt::print(fmt::fg(fmt::color::light_coral),
@@ -40,34 +55,36 @@ namespace Output {
}
void printArgClean() {
std::filesystem::path dirPath = "build";
std::error_code errorCode;
// std::filesystem::path dirPath = "build";
// std::error_code errorCode;
if (!std::filesystem::exists(dirPath, errorCode) || !std::filesystem::is_directory(dirPath, errorCode)) {
fmt::print(fmt::fg(fmt::color::light_coral),
"[Lazymake] Cleanup failed. Nothing to clean :(\n"
);
return;
}
std::filesystem::remove_all(dirPath, errorCode);
// for (const auto& entry : std::filesystem::directory_iterator(dirPath)) {
// std::filesystem::remove_all(entry.path());
// 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;
// }
if (errorCode) {
fmt::print(fmt::fg(fmt::color::light_coral),
"[Lazymake] Error! Could not clean up build directory :(\n {}\n", errorCode.message()
if (checkValidBuildDir()) {
std::filesystem::remove_all(buildDir, errorCode);
// for (const auto& entry : std::filesystem::directory_iterator(dirPath)) {
// std::filesystem::remove_all(entry.path());
// }
if (errorCode) {
fmt::print(fmt::fg(fmt::color::light_coral),
"[Lazymake] Error! Could not clean up build directory :(\n {}\n", errorCode.message()
);
return;
}
std::filesystem::create_directory(buildDir, errorCode);
fmt::print(fmt::fg(fmt::color::light_green),
"[Lazymake] Cleaned up build directory :D\n"
);
return;
}
std::filesystem::create_directory(dirPath, errorCode);
fmt::print(fmt::fg(fmt::color::light_green),
"[Lazymake] Cleaned up build directory :D\n"
);
}
void printArgVersion() {
@@ -106,4 +123,12 @@ namespace Output {
);
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>
namespace Output {
bool checkValidBuildDir();
void printMenu();
void printArgClean();
void printArgVersion();
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");
}
if (std::string_view(argv[1]) == "run") {
Output::runBuild();
}
if (std::string_view(argv[1]) == "clean") {
Output::printArgClean();
}