24 #ifndef CLOE_UTILITY_COMMAND_HPP_ 25 #define CLOE_UTILITY_COMMAND_HPP_ 30 #include <boost/filesystem/path.hpp> 82 {
"executable", executable.native()},
91 boost::filesystem::path
executable()
const {
return executable_; }
96 const std::vector<std::string>&
args()
const {
return args_; }
106 Verbosity verbosity()
const {
return output_; }
109 return std::move(*
this);
111 void set_verbosity(
Verbosity v) { output_ = v; }
113 Mode mode()
const {
return mode_; }
116 return std::move(*
this);
118 void set_mode(
Mode m) { mode_ = m; }
120 Command sync() && {
return std::move(*this).mode(Mode::Sync); }
121 bool is_sync()
const {
return mode() == Mode::Sync; }
124 bool is_async()
const {
return mode() ==
Mode::Async; }
127 bool is_detach()
const {
return mode() ==
Mode::Detach; }
129 bool ignore_failure()
const {
return ignore_failure_; }
130 Command ignore_failure(
bool v) && {
131 set_ignore_failure(v);
132 return std::move(*
this);
134 void set_ignore_failure(
bool v) { ignore_failure_ = v; }
142 {
"path", make_schema(&executable_,
"path to executable").require().not_empty().executable()},
143 {
"args", make_schema(&args_,
"arguments to executable")},
144 {
"mode", make_schema(&mode_,
"synchronization mode to use")},
145 {
"output", make_schema(&output_,
"how to log command output")},
146 {
"ignore_failure", make_schema(&ignore_failure_,
"whether to ignore execution failure")},
149 {
"command", make_schema(&command_,
"command to execute within shell").require().not_empty()},
150 {
"mode", make_schema(&mode_,
"synchronization mode to use")},
151 {
"output", make_schema(&output_,
"how to log command output")},
152 {
"ignore_failure", make_schema(&ignore_failure_,
"whether to ignore execution failure")},
154 String{&command_,
"command to execute within shell"}.not_empty(),
162 boost::filesystem::path executable_;
163 std::vector<std::string> args_;
164 std::string command_;
165 Mode mode_ = Mode::Sync;
167 bool ignore_failure_ =
false;
172 {Command::Mode::Sync,
"sync"},
178 {Command::Verbosity::Never,
"never"},
186 #endif // CLOE_UTILITY_COMMAND_HPP_
void from_conf(const Conf &c) override
Definition: command.cpp:70
Definition: confable.hpp:46
Definition: command.hpp:52
std::string command() const
Definition: command.cpp:62
Definition: coordinator.hpp:36
Verbosity
Definition: command.hpp:66
Schema & schema()
Definition: confable.cpp:55
boost::filesystem::path executable() const
Definition: command.hpp:91
#define ENUM_SERIALIZATION(xType, xMap)
Definition: enum.hpp:52
run command in background but wait for completion at destruction
Mode
Definition: command.hpp:57
run command and wait for completion
const std::vector< std::string > & args() const
Definition: command.hpp:96
log combined error when an error occurs