From 33b49dd7a5c76d594b2e3df2a7f2ec8a975c139c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 14 Apr 2022 18:00:49 +0200 Subject: [PATCH] Make the process building functions chainable --- src/common/process.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common/process.h b/src/common/process.h index 4adc3789..8cfceea5 100644 --- a/src/common/process.h +++ b/src/common/process.h @@ -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