79 Command(
const std::filesystem::path&
executable, std::initializer_list<std::string>
args) {
90 std::filesystem::path
executable()
const {
return executable_; }
95 const std::vector<std::string>&
args()
const {
return args_; }
105 Verbosity verbosity()
const {
return log_output_; }
108 return std::move(*
this);
110 void set_verbosity(
Verbosity v) { log_output_ = v; }
112 Mode mode()
const {
return mode_; }
113 Command mode(
Mode m) && {
115 return std::move(*
this);
117 void set_mode(
Mode m) { mode_ = m; }
119 Command sync() && {
return std::move(*this).mode(Mode::Sync); }
120 bool is_sync()
const {
return mode() == Mode::Sync; }
122 Command async() && {
return std::move(*this).mode(
Mode::Async); }
123 bool is_async()
const {
return mode() ==
Mode::Async; }
125 Command detach() && {
return std::move(*this).mode(
Mode::Detach); }
126 bool is_detach()
const {
return mode() ==
Mode::Detach; }
128 bool ignore_failure()
const {
return ignore_failure_; }
129 Command ignore_failure(
bool v) && {
130 set_ignore_failure(v);
131 return std::move(*
this);
133 void set_ignore_failure(
bool v) { ignore_failure_ = v; }
136 CONFABLE_SCHEMA(Command) {
141 {
"path", make_schema(&executable_,
"path to executable").require().not_empty().executable()},
142 {
"args", make_schema(&args_,
"arguments to executable")},
143 {
"mode", make_schema(&mode_,
"synchronization mode to use")},
144 {
"log_output", make_schema(&log_output_,
"how to log command output")},
145 {
"ignore_failure", make_schema(&ignore_failure_,
"whether to ignore execution failure")},
148 {
"command", make_schema(&command_,
"command to execute within shell").require().not_empty()},
149 {
"mode", make_schema(&mode_,
"synchronization mode to use")},
150 {
"log_output", make_schema(&log_output_,
"how to log command output")},
151 {
"ignore_failure", make_schema(&ignore_failure_,
"whether to ignore execution failure")},
153 String{&command_,
"command to execute within shell"}.not_empty(),
161 std::filesystem::path executable_;
162 std::vector<std::string> args_;
163 std::string command_;
164 Mode mode_ = Mode::Sync;
166 bool ignore_failure_ =
false;
171 {Command::Mode::Sync,
"sync"},
177 {Command::Verbosity::Never,
"never"},
Definition: command.hpp:51
Verbosity
Definition: command.hpp:65
@ OnError
never log anything
@ Always
log combined error when an error occurs
std::string command() const
Definition: command.cpp:63
void from_conf(const Conf &c) override
Definition: command.cpp:71
Mode
Definition: command.hpp:56
@ Async
run command and wait for completion
@ Detach
run command in background but wait for completion at destruction
std::filesystem::path executable() const
Definition: command.hpp:90
const std::vector< std::string > & args() const
Definition: command.hpp:95
Definition: confable.hpp:98
Schema & schema()
Definition: confable.cpp:47
#define ENUM_SERIALIZATION(xType, xMap)
Definition: enum.hpp:51