New commands!!!

This commit is contained in:
2026-05-12 03:05:47 +02:00
parent 07ecdeea01
commit 3ffd5000e7
3 changed files with 55 additions and 3 deletions

View File

@@ -1,11 +1,12 @@
#include "Output.hpp"
#include <cstdint>
#include <cstddef>
#include <filesystem>
#include "fmt/base.h"
#include "fmt/color.h"
#include <cstdlib>
#include <cstdio>
#include <system_error>
namespace Output {
@@ -15,10 +16,10 @@ namespace Output {
fmt::print(fmt::fg(fmt::color::light_coral),
" init [executable|library|shared|static|interface] Starts a new project in the same directory.\n"
);
fmt::print(fmt::fg(fmt::color::light_coral),
fmt::print(fmt::fg(fmt::color::light_green),
" gen Generates CMakeLists.txt file.\n"
);
fmt::print(fmt::fg(fmt::color::light_coral),
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),
@@ -72,4 +73,37 @@ namespace Output {
void printArgVersion() {
fmt::print("Version: 0.0.1 (Early pre-pre-pre-pre alpha\n");
}
int executeCommand(const std::string& command, const std::string& successMsg) {
FILE* pipe = popen(command.c_str(), "r");
if (!pipe) {
fmt::print(fmt::fg(fmt::color::light_coral),
"[Lazymake] Error! Could not execute command :(\n"
);
return -1;
}
char buffer[256];
while (fgets(buffer, sizeof(buffer), pipe) != nullptr) {
fmt::print("{}", buffer);
// std::string line(buffer);
// std::string target = "[cmkr]";
// size_t pos = line.find(target);
// if (pos != std::string::npos) {
// line.erase(pos, target.length() + 1);
// fmt::print("{}", line);
// } else {
// fmt::print("{}", buffer);
// }
}
int status = pclose(pipe);
fmt::print(fmt::fg(fmt::color::light_green),
"[Lazymake] {}\n", successMsg
);
return status;
}
}