From 34b71000b9e7a3db54c7826c790dfc1781ad430a Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 3 Feb 2021 09:08:30 +0100 Subject: Support options, e.g. --twofirst as arguments to it::cdist() --- it.class | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index aad3d92..513512a 100644 --- a/it.class +++ b/it.class @@ -742,15 +742,20 @@ static function cexec(/* $cmd, $values1 = array(), ... */) /** * distribute local files to all cluster hosts of the current service. no stderr if called with @ - * @params $files filename or array of files to distribute + * @params $args Variable number of options (e.g. --twofirst), filename or array of files to distribute * @see it::exec, /opt/ultra/bin/cdist */ -static function cdist(/* $file1, ... */) +static function cdist(...$args) { - foreach (func_get_args() as $arg) - $files = array_merge((array)$files, (array)$arg); + foreach ($args as $arg) + { + if (is_string($arg) && $arg[0] == '-') + $opts[$arg] = true; + else + $files = array_merge((array)$files, (array)$arg); + } - return ($errs = it::exec('cdist -q {FILES} 2>&1', ['FILES' => $files])) ? it::error(['title' => $errs]) : true; + return ($errs = it::exec('cdist -q {-opts} {files} 2>&1', ['-opts' => $opts, 'files' => $files])) ? it::error(['title' => $errs]) : true; } -- cgit v1.2.3