nur-sery/nur_src/mapper/json/YamlReader_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 YamlReader_command: classe de support pour construire une instance de
* {@link YamlReader} pour une application recevant des commandes utilisateurs
*/
class YamlReader_command {
use Tparams_command;
const NAME = "inyaml";
const DEF = [self::NAME, "inl",
"help" => "configurer le fichier en entrée 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"],
],
],
];
const F_OPTION = ["-f", "--input", "args" => "file",
"action" => [self::class, "set_file"],
];
/** @var YamlReader */
private static $command;
static function create_command() {
self::$command = new YamlReader();
}
static function set_file($file) {
$file = A::last(A::with($file));
self::get()->setInput($file);
}
}