25#include "absl/log/check.h"
26#include "absl/strings/string_view.h"
50 template <
typename T,
typename...
Args>
92 return std::move(
SetName(std::move(name)));
108 return std::move(
SetStopper(std::move(stopper)));
114 env_ = std::move(env);
122 absl::string_view value) &;
124 absl::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:114
std::vector< std::string > command_
Definition: command.h:202
std::map< SharedFD, int > inherited_fds_
Definition: command.h:204
Command SetExecutable(std::string executable) &&
Definition: command.h:83
Command & RedirectStdIO(StdIoChannel channel, SharedFD shared_fd) &
Definition: command.cc:184
friend std::ostream & operator<<(std::ostream &out, const Command &command)
Definition: command.cc:324
Command(std::string executable, SubprocessStopper stopper=KillSubprocess)
Definition: command.cc:106
Command & SetExecutable(std::string executable) &
Definition: command.h:79
void BuildParameter(std::stringstream *stream, T t)
Definition: command.h:42
std::string GetShortName() const
Definition: command.h:185
Command & AddEnvironmentVariable(absl::string_view env_var, absl::string_view value) &
Definition: command.cc:146
Command & AddPrerequisite(const std::function< Result< void >()> &prerequisite) &
Definition: command.cc:229
SharedFD working_directory_
Definition: command.h:208
std::string AsBashScript(const std::string &redirected_stdio_path="") const
Definition: command.cc:349
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:241
std::string ToString() const
Definition: command.cc:341
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
Command & UnsetFromEnvironment(absl::string_view env_var) &
Definition: command.cc:158
StdIoChannel
Definition: command.h:57
Command & SetWorkingDirectory(const std::string &path) &
Definition: command.cc:211
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:125
Definition: subprocess_options.h:22
Definition: subprocess.h:45
Definition: alloc_driver.h:21
StopperResult KillSubprocess(Subprocess *subprocess)
Definition: subprocess.cc:138
std::function< StopperResult(Subprocess *)> SubprocessStopper
Definition: subprocess.h:35
std::ostream & operator<<(std::ostream &out, DeviceType device_type)
Definition: device_type.cpp:73
tl::expected< T, StackTraceError< E > > Result
Definition: result_type.h:30
std::vector< std::string_view > Args
Definition: incremental.h:28