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 "Output.hpp"
#include <cstdint> #include <cstddef>
#include <filesystem> #include <filesystem>
#include "fmt/base.h" #include "fmt/base.h"
#include "fmt/color.h" #include "fmt/color.h"
#include <cstdlib> #include <cstdlib>
#include <cstdio>
#include <system_error> #include <system_error>
namespace Output { namespace Output {
@@ -15,10 +16,10 @@ namespace Output {
fmt::print(fmt::fg(fmt::color::light_coral), fmt::print(fmt::fg(fmt::color::light_coral),
" init [executable|library|shared|static|interface] Starts a new project in the same directory.\n" " 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" " 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" " build <extra cmake args> Run cmake and build.\n"
); );
fmt::print(fmt::fg(fmt::color::light_coral), fmt::print(fmt::fg(fmt::color::light_coral),
@@ -72,4 +73,37 @@ namespace Output {
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");
} }
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;
}
} }

View File

@@ -1,7 +1,11 @@
#pragma once #pragma once
#include <string>
namespace Output { namespace Output {
void printMenu(); void printMenu();
void printArgClean(); void printArgClean();
void printArgVersion(); void printArgVersion();
int executeCommand(const std::string& command, const std::string& successMsg);
} }

View File

@@ -1,3 +1,4 @@
#include <string>
#include <string_view> #include <string_view>
#include "Output.hpp" #include "Output.hpp"
@@ -15,6 +16,19 @@ int main(int argc, char* argv[]) {
return 0; return 0;
} }
if (std::string_view(argv[1]) == "gen") {
Output::executeCommand("cmkr gen", "Cmake generation completed :D");
}
if (std::string_view(argv[1]) == "install") {
Output::executeCommand("cmkr install", "CMake install completed :D");
}
// TODO: cmkr build with args
if (std::string_view(argv[1]) == "build") {
Output::executeCommand("cmkr build", "Cmake build completed :D");
}
if (std::string_view(argv[1]) == "clean") { if (std::string_view(argv[1]) == "clean") {
Output::printArgClean(); Output::printArgClean();
} }