28 #include <boost/filesystem/path.hpp>
80 Command(boost::filesystem::path
executable, std::initializer_list<std::string>
args) {
91 boost::filesystem::path
executable()
const {
return executable_; }
96 const std::vector<std::string>&
args()
const {
return args_; }
106 Verbosity verbosity()
const {
return log_output_; }
109 return std::move(*
this);
111 void set_verbosity(
Verbosity v) { log_output_ = v; }
113 Mode mode()
const {
return mode_; }
114 Command mode(
Mode m) && {
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; }
123 Command async() && {
return std::move(*this).mode(
Mode::Async); }
124 bool is_async()
const {
return mode() ==
Mode::Async; }
126 Command detach() && {
return std::move(*this).mode(
Mode::Detach); }
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; }
137 CONFABLE_SCHEMA(Command) {
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 {
"log_output", make_schema(&log_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 {
"log_output", make_schema(&log_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"},
Definition: command.hpp:52
Verbosity
Definition: command.hpp:66
@ OnError
never log anything
@ Always
log combined error when an error occurs
std::string command() const
Definition: command.cpp:62
void from_conf(const Conf &c) override
Definition: command.cpp:70
Mode
Definition: command.hpp:57
@ Async
run command and wait for completion
@ Detach
run command in background but wait for completion at destruction
const std::vector< std::string > & args() const
Definition: command.hpp:96
boost::filesystem::path executable() const
Definition: command.hpp:91
Definition: confable.hpp:98
Schema & schema()
Definition: confable.cpp:47
#define ENUM_SERIALIZATION(xType, xMap)
Definition: enum.hpp:51