New commands!!!
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Output {
|
||||
void printMenu();
|
||||
void printArgClean();
|
||||
void printArgVersion();
|
||||
|
||||
int executeCommand(const std::string& command, const std::string& successMsg);
|
||||
}
|
||||
|
||||
14
src/main.cpp
14
src/main.cpp
@@ -1,3 +1,4 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "Output.hpp"
|
||||
@@ -15,6 +16,19 @@ int main(int argc, char* argv[]) {
|
||||
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") {
|
||||
Output::printArgClean();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user