nur-sery/nur_src/mapper/json/YamlWriter_command.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2024-04-04 16:26:22 +04:00
<?php
namespace nur\mapper\json;
use nur\A;
use nur\mapper\base\Tparams_command;
/**
* Class YamlWriter_command: classe de support pour construire une instance de
* {@link YamlWriter} pour une application recevant des commandes utilisateurs
*/
class YamlWriter_command {
use Tparams_command;
const O_OPTION = ["-o", "--output", "args" => "file",
"action" => [self::class, "set_file"],
];
const NAME = "outyaml";
const DEF = [self::NAME, "outl",
"help" => "configurer le fichier en sortie au format YAML",
"action" => [self::class, "create_command"],
"cmd_args" => [
"usage" => self::NAME." [file]",
["-o", "--param", "args" => "value",
"action" => [self::class, "add_params"],
"help" => "spécifier une option générique",
],
["args" => [["file"]],
"action" => [self::class, "set_file"],
],
],
];
/** @var YamlWriter */
private static $command;
static function create_command() {
self::$command = new YamlWriter();
}
static function set_file($file) {
$file = A::last(A::with($file));
self::get()->setOutput($file);
}
}