52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
|
<?php
|
||
|
namespace nur\mapper\fsv;
|
||
|
|
||
|
use nur\mapper\base\mappers_command;
|
||
|
use nur\mapper\base\Tparams_command;
|
||
|
|
||
|
/**
|
||
|
* Class Fsv2AssocMapper_command: classe de support pour construire une instance
|
||
|
* de mapper pour une application recevant des commandes utilisateurs
|
||
|
*/
|
||
|
class Fsv2AssocMapper_command {
|
||
|
use Tparams_command;
|
||
|
|
||
|
const NAME = "fsv2assoc";
|
||
|
const DEF = [self::NAME,
|
||
|
"help" => "analyser un flux FSV",
|
||
|
"action" => [self::class, "create_command"],
|
||
|
"cmd_args" => [
|
||
|
"usage" => self::NAME,
|
||
|
["-r", "--run-code", "args" => "value",
|
||
|
"action" => [self::class, "set_schema_from_code"],
|
||
|
"help" => "exécuter le code et utiliser sa valeur de retour comme schéma",
|
||
|
],
|
||
|
["-f", "--run-file", "args" => "file",
|
||
|
"action" => [self::class, "set_schema_from_file"],
|
||
|
"help" => "exécuter le fichier et utiliser sa valeur de retour comme schéma",
|
||
|
],
|
||
|
["-o", "--param", "args" => "value",
|
||
|
"action" => [self::class, "add_params"],
|
||
|
"help" => "spécifier une option générique",
|
||
|
],
|
||
|
],
|
||
|
];
|
||
|
|
||
|
/** @var Fsv2AssocMapper */
|
||
|
protected static $command;
|
||
|
|
||
|
static function create_command() {
|
||
|
self::$command = mappers_command::add(new Fsv2AssocMapper());
|
||
|
}
|
||
|
|
||
|
static function set_schema_from_code(string $code) {
|
||
|
$schema = eval($code);
|
||
|
self::get()->setFsvSchema($schema);
|
||
|
}
|
||
|
|
||
|
static function set_schema_from_file(string $file) {
|
||
|
$schema = require($file);
|
||
|
self::get()->setFsvSchema($schema);
|
||
|
}
|
||
|
}
|