46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
|
<?php
|
||
|
namespace nur\mapper\json;
|
||
|
|
||
|
use nur\A;
|
||
|
use nur\mapper\base\Tparams_command;
|
||
|
|
||
|
/**
|
||
|
* Class JsonReader_command: classe de support pour construire une instance de
|
||
|
* {@link JsonReader} pour une application recevant des commandes utilisateurs
|
||
|
*/
|
||
|
class JsonReader_command {
|
||
|
use Tparams_command;
|
||
|
|
||
|
const NAME = "injson";
|
||
|
const DEF = [self::NAME, "inj",
|
||
|
"help" => "configurer le fichier en entrée au format JSON",
|
||
|
"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 JsonReader */
|
||
|
private static $command;
|
||
|
|
||
|
static function create_command() {
|
||
|
self::$command = new JsonReader();
|
||
|
}
|
||
|
|
||
|
static function set_file($file) {
|
||
|
$file = A::last(A::with($file));
|
||
|
self::get()->setInput($file);
|
||
|
}
|
||
|
}
|