26#include "absl/log/check.h"
50 template <
typename T,
typename...
Args>
108 return std::move(
SetStopper(std::move(stopper)));
114 env_ = std::move(env);
122 std::string_view value) &;
124 std::string_view value) &&;
136 template <
typename...
Args>
138 std::stringstream ss;
143 template <
typename...
Args>
145 return std::move(
AddParameter(std::forward<Args>(args)...));
152 template <
typename...
Args>
154 CHECK(!
command_.empty()) <<
"There is no parameter to append to.";
155 std::stringstream ss;
160 template <
typename...
Args>
197 std::string
AsBashScript(
const std::string& redirected_stdio_path =
"")
const;
206 std::vector<std::string>
env_{};
~Command()
Definition: command.cc:113
std::vector< std::string > command_
Definition: command.h:202
std::map< SharedFD, int > inherited_fds_
Definition: command.h:204
Command & AddEnvironmentVariable(std::string_view env_var, std::string_view value) &
Definition: command.cc:145
Command SetExecutable(std::string executable) &&
Definition: command.h:83
Command & RedirectStdIO(StdIoChannel channel, SharedFD shared_fd) &
Definition: command.cc:183
friend std::ostream & operator<<(std::ostream &out, const Command &command)
Definition: command.cc:336
Command(std::string executable, SubprocessStopper stopper=KillSubprocess)
Definition: command.cc:105
Command & SetExecutable(std::string executable) &
Definition: command.h:79
Command & UnsetFromEnvironment(std::string_view env_var) &
Definition: command.cc:157
void BuildParameter(std::stringstream *stream, T t)
Definition: command.h:42
std::string GetShortName() const
Definition: command.h:185
Command & AddPrerequisite(const std::function< Result< void >()> &prerequisite) &
Definition: command.cc:234
SharedFD working_directory_
Definition: command.h:208
std::string AsBashScript(const std::string &redirected_stdio_path="") const
Definition: command.cc:361
void BuildParameter(std::stringstream *stream, T &&t, Args &&... args)
Definition: command.h:51
std::vector< std::string > env_
Definition: command.h:206
Command(const Command &)=delete
const std::string & Executable() const
Definition: command.h:75
std::map< StdIoChannel, int > redirects_
Definition: command.h:205
Subprocess Start(SubprocessOptions options=SubprocessOptions()) const
Definition: command.cc:246
std::string ToString() const
Definition: command.cc:353
Command & SetEnvironment(std::vector< std::string > env) &
Definition: command.h:113
Command & operator=(const Command &)=delete
Command SetExecutableAndName(std::string name) &&
Definition: command.h:99
std::vector< std::function< Result< void >()> > prerequisites_
Definition: command.h:203
Command AppendToLastParameter(Args... args) &&
Definition: command.h:161
Command SetEnvironment(std::vector< std::string > env) &&
Definition: command.h:117
Command & SetName(std::string name) &
Definition: command.h:87
Command SetStopper(SubprocessStopper stopper) &&
Definition: command.h:107
Command & SetExecutableAndName(std::string name) &
Definition: command.h:95
Command & AddParameter(Args &&... args) &
Definition: command.h:137
Command(Command &&)=default
Command SetName(std::string name) &&
Definition: command.h:91
Command & AppendToLastParameter(Args... args) &
Definition: command.h:153
StdIoChannel
Definition: command.h:57
Command & SetWorkingDirectory(const std::string &path) &
Definition: command.cc:210
std::optional< std::string > executable_
Definition: command.h:201
SubprocessStopper subprocess_stopper_
Definition: command.h:207
Command & SetStopper(SubprocessStopper stopper) &
Definition: command.h:103
Command AddParameter(Args &&... args) &&
Definition: command.h:144
Definition: shared_fd.h:124
Definition: subprocess_options.h:22
Definition: subprocess.h:45
int options
Definition: f2fscrypt.c:124
#define CHECK(x)
Definition: logging.h:251
char * name
Definition: libf2fs.c:1403
Definition: alloc_driver.h:20
StopperResult KillSubprocess(Subprocess *subprocess)
Definition: subprocess.cc:137
std::function< StopperResult(Subprocess *)> SubprocessStopper
Definition: subprocess.h:35
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30
std::ostream & operator<<(std::ostream &out, DeviceType device_type)
Definition: device_type.cpp:72
std::vector< std::string_view > Args
Definition: incremental.h:28