Make the process building functions chainable

This commit is contained in:
Robbert van der Helm
2022-04-14 18:00:49 +02:00
parent 8d40341ade
commit 33b49dd7a5
+10 -3
View File
@@ -183,16 +183,23 @@ class Process {
Process(std::string command);
/**
* Add an argument to the command invocation.
* Add an argument to the command invocation. Returns a reference to this
* object for easier chaining.
*/
inline void arg(std::string arg) { args_.emplace_back(std::move(arg)); }
inline Process& arg(std::string arg) {
args_.emplace_back(std::move(arg));
return *this;
}
/**
* Use the specified environment for this command.
*
* @see environment
*/
inline void environment(ProcessEnvironment env) { env_ = std::move(env); }
inline Process& environment(ProcessEnvironment env) {
env_ = std::move(env);
return *this;
}
/**
* Spawn the process, leave STDIN, redirect STDERR to `/dev/null`, and