diff --git a/composer.json b/composer.json index 03c0a02..698923c 100644 --- a/composer.json +++ b/composer.json @@ -65,7 +65,6 @@ } }, "bin": [ - "lib/_launch.php", "nur_bin/compctl.php", "nur_bin/compdep.php", "nur_bin/cachectl.php", diff --git a/src/ext/yaml.php b/src/ext/yaml.php new file mode 100644 index 0000000..0b63bdd --- /dev/null +++ b/src/ext/yaml.php @@ -0,0 +1,35 @@ +getContents(); + try { + return cl::with(SymfonyYaml::parse($contents)); + } catch (ParseException $e) { + $message = "parse error"; + if (is_string($input)) $message .= " while loading $input"; + throw new IOException($message, 0, $e); + } + } + + static final function with($data, int $indent=2, int $flags=0): string { + return SymfonyYaml::dump($data, PHP_INT_MAX, $indent, $flags); + } + + static final function dump($data, $output=null, int $indent=2, int $flags=0): void { + file::writer($output)->putContents(self::with($data, $indent, $flags)); + } +} diff --git a/src/output/std/StdMessenger.php b/src/output/std/StdMessenger.php index 6468a69..2670213 100644 --- a/src/output/std/StdMessenger.php +++ b/src/output/std/StdMessenger.php @@ -7,7 +7,6 @@ use nur\sery\cl; use nur\sery\ExceptionShadow; use nur\sery\output\IMessenger; use nur\sery\UserException; -use nur\SL; use Throwable; class StdMessenger implements _IMessenger { @@ -242,7 +241,7 @@ class StdMessenger implements _IMessenger { int $indentLevel, StdOutput $out): void { $prefixes = self::GENERIC_PREFIXES[$level][$type]; if ($prefixes[0]) $out->print(); - $content = SL::with($content); + $content = cl::with($content); if ($out->isColor()) { $before = $prefixes[2]; $prefix = $prefixes[3]; @@ -362,7 +361,7 @@ class StdMessenger implements _IMessenger { string $type, $content, int $indentLevel, StdOutput $out): void { $prefixes = self::GENERIC_PREFIXES[$level][$type]; - $content = SL::with($content); + $content = cl::with($content); if ($out->isColor()) { $prefix = $prefixes[1]; $prefix2 = null; diff --git a/src/tools/BgLauncherApp.php b/src/tools/BgLauncherApp.php index 25dd365..2f1146f 100644 --- a/src/tools/BgLauncherApp.php +++ b/src/tools/BgLauncherApp.php @@ -2,6 +2,7 @@ namespace nur\sery\tools; use nur\sery\ExitError; +use nur\sery\ext\yaml; use nur\sery\os\path; use nur\sery\os\proc\Cmd; use nur\sery\os\sh; @@ -9,7 +10,6 @@ use nur\sery\output\msg; use nur\sery\app\app; use nur\sery\app\cli\Application; use nur\sery\app\RunFile; -use nur\yaml; class BgLauncherApp extends Application { const ACTION_INFOS = 0, ACTION_START = 1, ACTION_STOP = 2;