Improved runtime and script classes
This commit is contained in:
@ -38,9 +38,26 @@ class Environment
|
||||
|
||||
public function runScript(string $name, array $args, InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$script = $this->config['scripts'][$name];
|
||||
$script = $this->config['scripts'][$name]??$name;
|
||||
|
||||
if (is_string($script)) {
|
||||
$this->execScript($script, $args);
|
||||
} elseif (is_array($script)) {
|
||||
foreach ($script as $row) {
|
||||
$a = str_getcsv($row, ' ', "'");
|
||||
$c = array_shift($a);
|
||||
if (str_starts_with($c, '@')) {
|
||||
$c = ($this->config['scripts'][substr($c,1)])??$c;
|
||||
$this->runScript($c, $a, $input, $output);
|
||||
} else {
|
||||
$this->execScript($c, $a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function execScript(string $script, array $args)
|
||||
{
|
||||
// call script directly
|
||||
if (str_ends_with($script, '.php')) {
|
||||
$GLOBALS['args'] = $args;
|
||||
@ -50,11 +67,12 @@ class Environment
|
||||
fprintf(STDERR, "error: Could not find script file %s\n", $base."/".$script);
|
||||
return;
|
||||
}
|
||||
//echo "# ".$base."/".$script."\n";
|
||||
include $base . "/" . $script;
|
||||
} else {
|
||||
//echo "$ {$script}\n";
|
||||
passthru($script);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function loadEnvironment()
|
||||
|
Reference in New Issue
Block a user