Add colored, run scripts
This commit is contained in:
parent
51188e9f8e
commit
6decd7bc4b
7 changed files with 36 additions and 45 deletions
|
@ -10,7 +10,10 @@
|
|||
#include <cppshell/shell.hpp>
|
||||
#undef SIGPIPE_ALWAYS_IGNORE
|
||||
|
||||
#include <rang.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <ranges>
|
||||
#include <functional>
|
||||
|
||||
namespace clippy::targets {
|
||||
|
@ -58,11 +61,26 @@ class RunShellScript : public Target {
|
|||
void Execute() override {
|
||||
cppshell::Shell s;
|
||||
|
||||
for (auto& i : commands_) {
|
||||
std::cout << "-> " << i << std::endl;
|
||||
s.Execute(i);
|
||||
for (auto& command : commands_) {
|
||||
std::cout << rang::fg::green << rang::style::bold << "-> "
|
||||
<< rang::fg::reset << command << rang::style::reset
|
||||
<< std::endl;
|
||||
s.Execute(command);
|
||||
if (int err = s.GetExitCodeLastCommand(); err != 0) {
|
||||
std::cout << "ERROR" << std::endl;
|
||||
std::cout << rang::fg::red << rang::style::bold
|
||||
<< "Command exit with code " << err << rang::fg::reset
|
||||
<< rang::style::reset << std::endl;
|
||||
std::cout << rang::fg::blue << rang::style::bold
|
||||
<< "Continue execution? [Y/n] " << rang::fg::reset
|
||||
<< rang::style::reset;
|
||||
|
||||
std::string result;
|
||||
std::getline(std::cin, result);
|
||||
if (result == "" || result == "y") {
|
||||
continue;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue