diff --git a/lib/_launch.php b/lib/_launch.php index 693b89b..9c34847 100755 --- a/lib/_launch.php +++ b/lib/_launch.php @@ -11,6 +11,7 @@ $argv = array_merge( ); $app_params = unserialize(file_get_contents($paramsfile)); +@unlink($paramsfile); require $app_params["vendor"]["autoload"]; use nur\cli\Application; diff --git a/src/app/launcher.php b/src/app/launcher.php index 5667bfe..181d1a2 100644 --- a/src/app/launcher.php +++ b/src/app/launcher.php @@ -3,6 +3,7 @@ namespace nur\sery\app; use nur\sery\cl; use nur\sery\file\TmpfileWriter; +use nur\sery\os\path; use nur\sery\os\proc\Cmd; use nur\sery\output\msg; use nur\sery\StateException; @@ -18,24 +19,28 @@ class launcher { * - les valeurs séquentielles sont prises telles quelles */ static function verifix_args(array $args): array { - if (cl::is_list($args)) return $args; - $fixedArgs = []; - $index = 0; - foreach ($args as $arg => $value) { - if ($arg === $index) { - $index++; - $fixedArgs[] = $value; - continue; - } elseif ($value === false) { - continue; + if (!cl::is_list($args)) { + $fixedArgs = []; + $index = 0; + foreach ($args as $arg => $value) { + if ($arg === $index) { + $index++; + $fixedArgs[] = $value; + continue; + } elseif ($value === false) { + continue; + } + $arg = str::us2camel($arg); + $arg = str::camel2us($arg, false, "-"); + $arg = str_replace("_", "-", $arg); + $fixedArgs[] = "--$arg"; + if ($value !== true) $fixedArgs[] = "$value"; } - $arg = str::us2camel($arg); - $arg = str::camel2us($arg, false, "-"); - $arg = str_replace("_", "-", $arg); - $fixedArgs[] = "--$arg"; - if ($value !== true) $fixedArgs[] = "$value"; + $args = $fixedArgs; } - return $fixedArgs; + # corriger le chemin de l'application pour qu'il soit absolu et normalisé + $args[0] = path::abspath($args[0]); + return $args; } static function launch(string $appClass, array $args): int { @@ -46,7 +51,7 @@ class launcher { $launch_php = __DIR__."/../../lib/_launch.php"; } $tmpfile = new TmpfileWriter(); - $tmpfile->serialize($app->getParams()); + $tmpfile->keep()->serialize($app->getParams()); $args = self::verifix_args($args); $cmd = new Cmd([ diff --git a/src/file/TmpfileWriter.php b/src/file/TmpfileWriter.php index 65cb47b..f56046a 100644 --- a/src/file/TmpfileWriter.php +++ b/src/file/TmpfileWriter.php @@ -39,6 +39,12 @@ class TmpfileWriter extends FileWriter { /** @var bool */ protected $delete; + /** désactiver la suppression automatique du fichier temporaire */ + function keep(): self { + $this->delete = false; + return $this; + } + function __destruct() { $this->close(); if ($this->delete) $this->delete();