mirror of
https://github.com/build-cpp/cmkr
synced 2026-06-08 13:22:55 +00:00
fixes
This commit is contained in:
+23
-11
@@ -1,26 +1,34 @@
|
||||
#include "args.hpp"
|
||||
#include "gen.hpp"
|
||||
#include "help.hpp"
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include "args.h"
|
||||
#include "gen.h"
|
||||
#include "help.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <stddef.h>
|
||||
#include <stdexcept>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace cmkr::args {
|
||||
std::string handle_args(std::vector<std::string> &args) {
|
||||
const char *handle_args(int argc, char **argv) {
|
||||
std::vector<std::string> args;
|
||||
for (int i = 0; i < argc; ++i)
|
||||
args.push_back(argv[i]);
|
||||
|
||||
if (args.size() < 2)
|
||||
throw std::runtime_error("Please provide command line arguments!");
|
||||
std::string main_arg = args[1];
|
||||
if (main_arg == "gen") {
|
||||
cmkr::gen::generate_cmake();
|
||||
cmkr::gen::generate_cmake(std::filesystem::current_path().string().c_str());
|
||||
return "Generation successful!";
|
||||
} else if (main_arg == "help") {
|
||||
return cmkr::help::help_msg;
|
||||
return cmkr::help::message();
|
||||
} else if (main_arg == "version") {
|
||||
return cmkr::help::version;
|
||||
return cmkr::help::version();
|
||||
} else if (main_arg == "init") {
|
||||
if (args.size() < 3)
|
||||
throw std::runtime_error("Please provide a project type!");
|
||||
cmkr::gen::generate_project(args[2]);
|
||||
cmkr::gen::generate_project(args[2].c_str());
|
||||
return "Directory initialized!";
|
||||
} else if (main_arg == "build") {
|
||||
std::string command = "cmake -S. -Bbin ";
|
||||
@@ -38,4 +46,8 @@ std::string handle_args(std::vector<std::string> &args) {
|
||||
return "Unknown argument!";
|
||||
}
|
||||
}
|
||||
} // namespace cmkr::args
|
||||
} // namespace cmkr::args
|
||||
|
||||
const char *cmkr_args_handle_args(int argc, char **argv) {
|
||||
return cmkr::args::handle_args(argc, argv);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user