|
|
@ -5,10 +5,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <exception>
|
|
|
|
#include <exception>
|
|
|
|
#include <filesystem>
|
|
|
|
#include <filesystem>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
|
|
|
|
|
|
|
|
namespace cmkr::args {
|
|
|
|
namespace cmkr::args {
|
|
|
|
const char *handle_args(int argc, char **argv) {
|
|
|
|
const char *handle_args(int argc, char **argv) {
|
|
|
|
std::vector<std::string> args;
|
|
|
|
std::vector<std::string> args;
|
|
|
@ -19,7 +22,20 @@ const char *handle_args(int argc, char **argv) {
|
|
|
|
return "Please provide command line arguments!";
|
|
|
|
return "Please provide command line arguments!";
|
|
|
|
std::string main_arg = args[1];
|
|
|
|
std::string main_arg = args[1];
|
|
|
|
if (main_arg == "gen") {
|
|
|
|
if (main_arg == "gen") {
|
|
|
|
auto ret = cmkr::gen::generate_cmake(std::filesystem::current_path().string().c_str());
|
|
|
|
bool cont = false;
|
|
|
|
|
|
|
|
if (args.size() > 2 && args[2] == "-y")
|
|
|
|
|
|
|
|
cont = true;
|
|
|
|
|
|
|
|
auto current_path = fs::current_path();
|
|
|
|
|
|
|
|
if (fs::exists(current_path / "CMakeLists.txt") && cont == false) {
|
|
|
|
|
|
|
|
std::cout << "A CMakeLists.txt file already exists in the current directory.\nWould you "
|
|
|
|
|
|
|
|
"like to overwrite it?[y/n]"
|
|
|
|
|
|
|
|
<< std::endl;
|
|
|
|
|
|
|
|
std::string resp;
|
|
|
|
|
|
|
|
std::cin >> resp;
|
|
|
|
|
|
|
|
if (resp != "y")
|
|
|
|
|
|
|
|
return "CMake generation aborted!";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ret = cmkr::gen::generate_cmake(current_path.string().c_str());
|
|
|
|
if (ret)
|
|
|
|
if (ret)
|
|
|
|
return "CMake generation error!";
|
|
|
|
return "CMake generation error!";
|
|
|
|
return "CMake generation successful!";
|
|
|
|
return "CMake generation successful!";
|
|
|
|