52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
namespace nur\mapper\item;
|
|
|
|
use nur\mapper\base\mappers_command;
|
|
use nur\mapper\base\Tparams_command;
|
|
|
|
/**
|
|
* Class StringMapper_command: classe de support pour construire une instance de
|
|
* mapper pour une application recevant des commandes utilisateurs
|
|
*/
|
|
class StringMapper_command {
|
|
use Tparams_command;
|
|
|
|
const NAME = "string";
|
|
const DEF = [self::NAME, "str",
|
|
"help" => "faire des opérations sur des chaines",
|
|
"action" => [self::class, "create_command"],
|
|
"cmd_args" => [
|
|
"usage" => self::NAME,
|
|
["--mo", "--marked-only", "args" => "value", "type" => "bool",
|
|
"action" => [self::class, "set_marked_only"],
|
|
"help" => "indiquer si les opérations ne doivent être effectuées que sur les éléments marqués",
|
|
],
|
|
["-o", "--param", "args" => "value",
|
|
"action" => [self::class, "add_params"],
|
|
"help" => "spécifier une option générique",
|
|
],
|
|
["args" => [["value", null]],
|
|
"action" => [self::class, "add_actions"],
|
|
],
|
|
],
|
|
];
|
|
|
|
/** @var StringMapper */
|
|
protected static $command;
|
|
|
|
static function create_command() {
|
|
self::$command = mappers_command::add(new StringMapper());
|
|
}
|
|
|
|
static function set_marked_only(?bool $marked_only) {
|
|
self::get()->setMarkedOnly($marked_only);
|
|
}
|
|
|
|
static function add_actions(array $actions) {
|
|
$command = self::get();
|
|
foreach ($actions as $action) {
|
|
$command->addAction($action);
|
|
}
|
|
}
|
|
}
|