use return value

self-hosting
MoAlyousef 4 years ago
parent a44f4ee572
commit de29e1aacb

@ -1,6 +1,7 @@
#include "args.hpp" #include "args.hpp"
#include "gen.hpp" #include "gen.hpp"
#include "help.hpp" #include "help.hpp"
#include <cstddef>
#include <cstdlib> #include <cstdlib>
#include <stdexcept> #include <stdexcept>
@ -24,12 +25,14 @@ std::string handle_args(std::vector<std::string> &args) {
} else if (main_arg == "build") { } else if (main_arg == "build") {
std::string command = "cmake -S. -Bbin "; std::string command = "cmake -S. -Bbin ";
if (args.size() > 2) { if (args.size() > 2) {
for (int i = 2; i < args.size(); ++i) { for (size_t i = 2; i < args.size(); ++i) {
command += args[i] + " "; command += args[i] + " ";
} }
} }
command += "&& cmake --build bin"; command += "&& cmake --build bin";
auto _ = system(command.c_str()); auto ret = system(command.c_str());
if (ret)
return "Run faced an error!";
return "Run completed!"; return "Run completed!";
} else { } else {
return "Unknown argument!"; return "Unknown argument!";

Loading…
Cancel
Save