Skip to content

Commit

Permalink
adding fix for watch command
Browse files Browse the repository at this point in the history
  • Loading branch information
lsproule committed Nov 2, 2023
1 parent 9649c28 commit 3babbdd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Command/CommandRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Command {
std::string command = file_name + ctx->project_name;
success = system(command.c_str());
if (success != 0) {
std::cout << "Error running project" << std::endl;
std::cout << "Error running project!" << std::endl;
return false;
}

Expand Down
32 changes: 20 additions & 12 deletions src/Command/CommandDev.cpp → src/Command/CommandWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,28 @@ namespace Command {

watcher([this]() {
#ifdef DEBUG
std::vector<std::string> args_vec = args->operator[]("args").as<std::vector<std::string>>();
std::string command_args = std::accumulate(
std::string command = "cmake ./build/ && ./build/make && ./build/" + ctx->build_dir + "/" + ctx->project_name;
if (args->count("args") != 0) {
std::cout << "No args provided" << std::endl;
std::vector<std::string> args_vec = args->operator[]("args").as<std::vector<std::string>>();
std::string command_args = std::accumulate(
args_vec.begin(), args_vec.end(), args_vec[0],
[](std::string a, std::string b) { return a + " " + b; }
);
const std::string command = "cmake ./build/ && make && ./build/" + ctx->build_dir + "/" + ctx->project_name + " " +command_args;
#else
std::vector<std::string> args_vec = args->operator[]("args").as<std::vector<std::string>>();
std::string command_args = std::accumulate(
args_vec.begin(), args_vec.end(), args_vec[0],
[](std::string a, std::string b) { return a + " " + b; }
);
[](std::string a, std::string b) { return a + " " + b; });

const std::string command = "cmake . && make && ./" + ctx->build_dir + "/" + ctx->project_name + " " + command_args;
command = "cmake ./build/ && make && ./build/" + ctx->build_dir + "/" + ctx->project_name + " " +command_args;

}

#else
std::string command = "cmake . && make && ./" + ctx->build_dir + "/" + ctx->project_name;
if (args->count("args") != 0) {
std::string command = "cmake . && make && ./ " + ctx->build_dir + "/" + ctx->project_name;
std::vector<std::string> args_vec = args->operator[]("args").as<std::vector<std::string>>();
std::string command_args = std::accumulate(
args_vec.begin(), args_vec.end(), args_vec[0],
[](std::string a, std::string b) { return a + " " + b; }
);
}
#endif
int success = system(command.c_str());
if (success != 0) {
Expand Down

0 comments on commit 3babbdd

Please sign in to comment.