Better clean :D

This commit is contained in:
2026-05-07 16:59:19 +02:00
parent 7638d528ef
commit 5622ce97e5

View File

@@ -6,6 +6,7 @@
#include "fmt/base.h" #include "fmt/base.h"
#include "fmt/color.h" #include "fmt/color.h"
#include <cstdlib> #include <cstdlib>
#include <system_error>
namespace Output { namespace Output {
void printMenu() { void printMenu() {
@@ -39,18 +40,30 @@ namespace Output {
void printArgClean() { void printArgClean() {
std::filesystem::path dirPath = "build"; std::filesystem::path dirPath = "build";
std::error_code errorCode;
if (!std::filesystem::exists(dirPath) || !std::filesystem::is_directory(dirPath)) { if (!std::filesystem::exists(dirPath, errorCode) || !std::filesystem::is_directory(dirPath, 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;
}
std::filesystem::remove_all(dirPath, errorCode);
std::filesystem::remove_all(dirPath);
// 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());
// } // }
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(dirPath, 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"
); );