ajout nur/*
This commit is contained in:
86
nur_tbin/log.php
Executable file
86
nur_tbin/log.php
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/php
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\A;
|
||||
use nur\b\ValueException;
|
||||
use nur\cli\Application;
|
||||
use nur\log;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS = [
|
||||
"merge" => Application::ARGS,
|
||||
["-l:", "--level"],
|
||||
["-t:", "--type"],
|
||||
["-r:", "--result"],
|
||||
];
|
||||
private $args;
|
||||
private $level, $type, $result;
|
||||
|
||||
const LEVEL_MAP = [
|
||||
"1" => log::CRITICAL, "X" => log::CRITICAL,
|
||||
"2" => log::MAJOR, "M" => log::MAJOR,
|
||||
"3" => log::NORMAL, "n" => log::NORMAL,
|
||||
"4" => log::MINOR, "m" => log::MINOR,
|
||||
];
|
||||
const TYPE_MAP = [
|
||||
"1" => log::ERROR, "e" => log::ERROR,
|
||||
"2" => log::WARNING, "w" => log::WARNING,
|
||||
"3" => log::INFO, "i" => log::INFO,
|
||||
"4" => log::DEBUG, "d" => log::DEBUG,
|
||||
];
|
||||
const RESULT_MAP = [
|
||||
"0" => log::NONE, "n" => log::NONE,
|
||||
"1" => log::NEUTRAL, "s" => log::NEUTRAL,
|
||||
"2" => log::SUCCESS, "ok" => log::SUCCESS,
|
||||
"3" => log::FAILURE, "ko" => log::FAILURE,
|
||||
];
|
||||
|
||||
function main() {
|
||||
log::info("Profil sélectionné: ".self::profile());
|
||||
|
||||
log::action("calcul des arguments");
|
||||
$level = A::get(self::LEVEL_MAP, $this->level, log::NORMAL);
|
||||
$type = A::get(self::TYPE_MAP, $this->type, log::INFO);
|
||||
$result = A::get(self::RESULT_MAP, $this->result, log::NONE);
|
||||
log::asuccess();
|
||||
|
||||
if ($this->args) {
|
||||
$log = log::get();
|
||||
foreach($this->args as $message) {
|
||||
$log->addMessage($message, $type + $result, $level);
|
||||
}
|
||||
} else {
|
||||
log::error("error message");
|
||||
log::warning("warning message");
|
||||
log::note("note message");
|
||||
log::info("info message");
|
||||
log::step("step message");
|
||||
log::success("success message");
|
||||
log::failure("failure message");
|
||||
log::debug("debug message");
|
||||
log::group("action multiple 1");
|
||||
log::step("étape 1");
|
||||
log::asuccess("effectué avec succès");
|
||||
log::group("action multiple 2");
|
||||
log::step("étape 2.1");
|
||||
log::step("étape 2.2");
|
||||
log::afailure("erreur d'étape");
|
||||
log::action("fonction sans valeur de retour", function () {
|
||||
echo "sortie de la fonction sans valeur de retour\n";
|
||||
});
|
||||
log::action("fonction true", function () {
|
||||
return true;
|
||||
});
|
||||
log::action("fonction false", function () {
|
||||
return false;
|
||||
});
|
||||
log::action("fonction string", function () {
|
||||
return "résultat de la fonction string";
|
||||
});
|
||||
log::action("fonction exception", function () {
|
||||
throw new ValueException("message de l'exception");
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
86
nur_tbin/msg.php
Executable file
86
nur_tbin/msg.php
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/php
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\A;
|
||||
use nur\b\ValueException;
|
||||
use nur\cli\Application;
|
||||
use nur\msg;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS = [
|
||||
"merge" => Application::ARGS,
|
||||
["-l:", "--level"],
|
||||
["-t:", "--type"],
|
||||
["-r:", "--result"],
|
||||
];
|
||||
private $args;
|
||||
private $level, $type, $result;
|
||||
|
||||
const LEVEL_MAP = [
|
||||
"1" => msg::CRITICAL, "X" => msg::CRITICAL,
|
||||
"2" => msg::MAJOR, "M" => msg::MAJOR,
|
||||
"3" => msg::NORMAL, "n" => msg::NORMAL,
|
||||
"4" => msg::MINOR, "m" => msg::MINOR,
|
||||
];
|
||||
const TYPE_MAP = [
|
||||
"1" => msg::ERROR, "e" => msg::ERROR,
|
||||
"2" => msg::WARNING, "w" => msg::WARNING,
|
||||
"3" => msg::INFO, "i" => msg::INFO,
|
||||
"4" => msg::DEBUG, "d" => msg::DEBUG,
|
||||
];
|
||||
const RESULT_MAP = [
|
||||
"0" => msg::NONE, "n" => msg::NONE,
|
||||
"1" => msg::NEUTRAL, "s" => msg::NEUTRAL,
|
||||
"2" => msg::SUCCESS, "ok" => msg::SUCCESS,
|
||||
"3" => msg::FAILURE, "ko" => msg::FAILURE,
|
||||
];
|
||||
|
||||
function main() {
|
||||
msg::info("Profil sélectionné: ".self::profile());
|
||||
|
||||
msg::action("calcul des arguments");
|
||||
$level = A::get(self::LEVEL_MAP, $this->level, msg::NORMAL);
|
||||
$type = A::get(self::TYPE_MAP, $this->type, msg::INFO);
|
||||
$result = A::get(self::RESULT_MAP, $this->result, msg::NONE);
|
||||
msg::asuccess();
|
||||
|
||||
if ($this->args) {
|
||||
$msg = msg::get();
|
||||
foreach($this->args as $message) {
|
||||
$msg->addMessage($message, $type + $result, $level);
|
||||
}
|
||||
} else {
|
||||
msg::error("error message");
|
||||
msg::warning("warning message");
|
||||
msg::note("note message");
|
||||
msg::info("info message");
|
||||
msg::step("step message");
|
||||
msg::success("success message");
|
||||
msg::failure("failure message");
|
||||
msg::debug("debug message");
|
||||
msg::group("action multiple 1");
|
||||
msg::step("étape 1");
|
||||
msg::asuccess("effectué avec succès");
|
||||
msg::group("action multiple 2");
|
||||
msg::step("étape 2.1");
|
||||
msg::step("étape 2.2");
|
||||
msg::afailure("erreur d'étape");
|
||||
msg::action("fonction sans valeur de retour", function () {
|
||||
echo "sortie de la fonction sans valeur de retour\n";
|
||||
});
|
||||
msg::action("fonction true", function () {
|
||||
return true;
|
||||
});
|
||||
msg::action("fonction false", function () {
|
||||
return false;
|
||||
});
|
||||
msg::action("fonction string", function () {
|
||||
return "résultat de la fonction string";
|
||||
});
|
||||
msg::action("fonction exception", function () {
|
||||
throw new ValueException("message de l'exception");
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
70
nur_tbin/out.log
Normal file
70
nur_tbin/out.log
Normal file
@@ -0,0 +1,70 @@
|
||||
2023-08-17T11:57:23.916108 INFO: Profil sélectionné: devel
|
||||
2023-08-17T11:57:23.916720 (SUCCESS) calcul des arguments : succès
|
||||
2023-08-17T11:57:23.916990 ERROR: error message
|
||||
2023-08-17T11:57:23.917243 WARN: warning message
|
||||
2023-08-17T11:57:23.917607 IMPORTANT! note message
|
||||
2023-08-17T11:57:23.917841 INFO: info message
|
||||
2023-08-17T11:57:23.918069 * step message
|
||||
2023-08-17T11:57:23.918292 (SUCCESS) success message
|
||||
2023-08-17T11:57:23.918515 (FAILURE) failure message
|
||||
2023-08-17T11:57:23.918736 DEBUG: debug message
|
||||
2023-08-17T11:57:23.918916 > action multiple 1
|
||||
2023-08-17T11:57:23.919126 * étape 1
|
||||
2023-08-17T11:57:23.919397 (SUCCESS) effectué avec succès
|
||||
2023-08-17T11:57:23.919577 > action multiple 2
|
||||
2023-08-17T11:57:23.919779 * étape 2.1
|
||||
2023-08-17T11:57:23.920008 * étape 2.2
|
||||
2023-08-17T11:57:23.920324 (FAILURE) erreur d'étape
|
||||
2023-08-17T11:57:23.920603 (SUCCESS) fonction sans valeur de retour : succès
|
||||
2023-08-17T11:57:23.920877 (SUCCESS) fonction true : succès
|
||||
2023-08-17T11:57:23.921149 (FAILURE) fonction false : échec
|
||||
2023-08-17T11:57:23.921413 (SUCCESS) fonction string : résultat de la fonction string
|
||||
2023-08-17T11:57:23.921793 (FAILURE) fonction exception : erreur
|
||||
2023-08-17T11:57:23.921793 (FAILURE) TRACEBACK: nur\b\ValueException: erreur
|
||||
at /home/jclain/wop/php/nur-base/tbin/log.php(82)
|
||||
#0 [internal function]: class@anonymous->{closure}()
|
||||
#1 /home/jclain/wop/php/nur-base/src_api/func.php(238): ReflectionFunction->invoke()
|
||||
#2 /home/jclain/wop/php/nur-base/src_api/func.php(250): nur\func::_call()
|
||||
#3 /home/jclain/wop/php/nur-base/src_b/ui/AbstractMessenger.php(550): nur\func::call()
|
||||
#4 /home/jclain/wop/php/nur-base/src_b/ui/AbstractMessenger.php(609): nur\b\ui\AbstractMessenger->aresult()
|
||||
#5 /home/jclain/wop/php/nur-base/src_api/_messenger.php(105): nur\b\ui\AbstractMessenger->action()
|
||||
#6 /home/jclain/wop/php/nur-base/tbin/log.php(83): nur\_messenger::action()
|
||||
#7 /home/jclain/wop/php/nur-base/src_cli/Application.php(55): class@anonymous->main()
|
||||
#8 /home/jclain/wop/php/nur-base/src_cli/Application.php(66): nur\cli\Application::_app_main()
|
||||
#9 /home/jclain/wop/php/nur-base/tbin/log.php(10): nur\cli\Application::run()
|
||||
#10 {main}
|
||||
2023-08-17T11:57:44.798558 INFO: Profil sélectionné: devel
|
||||
2023-08-17T11:57:44.799144 (SUCCESS) calcul des arguments : succès
|
||||
2023-08-17T11:57:44.799415 ERROR: error message
|
||||
2023-08-17T11:57:44.799656 WARN: warning message
|
||||
2023-08-17T11:57:44.799886 IMPORTANT! note message
|
||||
2023-08-17T11:57:44.800109 INFO: info message
|
||||
2023-08-17T11:57:44.800329 * step message
|
||||
2023-08-17T11:57:44.800548 (SUCCESS) success message
|
||||
2023-08-17T11:57:44.800765 (FAILURE) failure message
|
||||
2023-08-17T11:57:44.800980 DEBUG: debug message
|
||||
2023-08-17T11:57:44.801156 > action multiple 1
|
||||
2023-08-17T11:57:44.801355 * étape 1
|
||||
2023-08-17T11:57:44.801615 (SUCCESS) effectué avec succès
|
||||
2023-08-17T11:57:44.801793 > action multiple 2
|
||||
2023-08-17T11:57:44.801990 * étape 2.1
|
||||
2023-08-17T11:57:44.802213 * étape 2.2
|
||||
2023-08-17T11:57:44.802507 (FAILURE) erreur d'étape
|
||||
2023-08-17T11:57:44.802787 (SUCCESS) fonction sans valeur de retour : succès
|
||||
2023-08-17T11:57:44.803063 (SUCCESS) fonction true : succès
|
||||
2023-08-17T11:57:44.803344 (FAILURE) fonction false : échec
|
||||
2023-08-17T11:57:44.803609 (SUCCESS) fonction string : résultat de la fonction string
|
||||
2023-08-17T11:57:44.803984 (FAILURE) fonction exception : erreur
|
||||
2023-08-17T11:57:44.803984 (FAILURE) TRACEBACK: nur\b\ValueException: erreur
|
||||
at /home/jclain/wop/php/nur-base/tbin/msg.php(82)
|
||||
#0 [internal function]: class@anonymous->{closure}()
|
||||
#1 /home/jclain/wop/php/nur-base/src_api/func.php(238): ReflectionFunction->invoke()
|
||||
#2 /home/jclain/wop/php/nur-base/src_api/func.php(250): nur\func::_call()
|
||||
#3 /home/jclain/wop/php/nur-base/src_b/ui/AbstractMessenger.php(550): nur\func::call()
|
||||
#4 /home/jclain/wop/php/nur-base/src_b/ui/AbstractMessenger.php(609): nur\b\ui\AbstractMessenger->aresult()
|
||||
#5 /home/jclain/wop/php/nur-base/src_api/_messenger.php(105): nur\b\ui\AbstractMessenger->action()
|
||||
#6 /home/jclain/wop/php/nur-base/tbin/msg.php(83): nur\_messenger::action()
|
||||
#7 /home/jclain/wop/php/nur-base/src_cli/Application.php(55): class@anonymous->main()
|
||||
#8 /home/jclain/wop/php/nur-base/src_cli/Application.php(66): nur\cli\Application::_app_main()
|
||||
#9 /home/jclain/wop/php/nur-base/tbin/msg.php(10): nur\cli\Application::run()
|
||||
#10 {main}
|
||||
86
nur_tbin/say.php
Executable file
86
nur_tbin/say.php
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/php
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\A;
|
||||
use nur\b\ValueException;
|
||||
use nur\cli\Application;
|
||||
use nur\say;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS = [
|
||||
"merge" => Application::ARGS,
|
||||
["-l:", "--level"],
|
||||
["-t:", "--type"],
|
||||
["-r:", "--result"],
|
||||
];
|
||||
private $args;
|
||||
private $level, $type, $result;
|
||||
|
||||
const LEVEL_MAP = [
|
||||
"1" => say::CRITICAL, "X" => say::CRITICAL,
|
||||
"2" => say::MAJOR, "M" => say::MAJOR,
|
||||
"3" => say::NORMAL, "n" => say::NORMAL,
|
||||
"4" => say::MINOR, "m" => say::MINOR,
|
||||
];
|
||||
const TYPE_MAP = [
|
||||
"1" => say::ERROR, "e" => say::ERROR,
|
||||
"2" => say::WARNING, "w" => say::WARNING,
|
||||
"3" => say::INFO, "i" => say::INFO,
|
||||
"4" => say::DEBUG, "d" => say::DEBUG,
|
||||
];
|
||||
const RESULT_MAP = [
|
||||
"0" => say::NONE, "n" => say::NONE,
|
||||
"1" => say::NEUTRAL, "s" => say::NEUTRAL,
|
||||
"2" => say::SUCCESS, "ok" => say::SUCCESS,
|
||||
"3" => say::FAILURE, "ko" => say::FAILURE,
|
||||
];
|
||||
|
||||
function main() {
|
||||
say::info("Profil sélectionné: ".self::profile());
|
||||
|
||||
say::action("calcul des arguments");
|
||||
$level = A::get(self::LEVEL_MAP, $this->level, say::NORMAL);
|
||||
$type = A::get(self::TYPE_MAP, $this->type, say::INFO);
|
||||
$result = A::get(self::RESULT_MAP, $this->result, say::NONE);
|
||||
say::asuccess();
|
||||
|
||||
if ($this->args) {
|
||||
$say = say::get();
|
||||
foreach($this->args as $message) {
|
||||
$say->addMessage($message, $type + $result, $level);
|
||||
}
|
||||
} else {
|
||||
say::error("error message");
|
||||
say::warning("warning message");
|
||||
say::note("note message");
|
||||
say::info("info message");
|
||||
say::step("step message");
|
||||
say::success("success message");
|
||||
say::failure("failure message");
|
||||
say::debug("debug message");
|
||||
say::group("action multiple 1");
|
||||
say::step("étape 1");
|
||||
say::asuccess("effectué avec succès");
|
||||
say::group("action multiple 2");
|
||||
say::step("étape 2.1");
|
||||
say::step("étape 2.2");
|
||||
say::afailure("erreur d'étape");
|
||||
say::action("fonction sans valeur de retour", function () {
|
||||
echo "sortie de la fonction sans valeur de retour\n";
|
||||
});
|
||||
say::action("fonction true", function () {
|
||||
return true;
|
||||
});
|
||||
say::action("fonction false", function () {
|
||||
return false;
|
||||
});
|
||||
say::action("fonction string", function () {
|
||||
return "résultat de la fonction string";
|
||||
});
|
||||
say::action("fonction exception", function () {
|
||||
throw new ValueException("message de l'exception");
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
62
nur_tbin/test-args1.php
Normal file
62
nur_tbin/test-args1.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\cli\Application;
|
||||
use nur\out;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS = [
|
||||
["-c", "--common", "help" => "option commune"],
|
||||
["one", "help" => "blah",
|
||||
"cmd_args" => [
|
||||
["-1", "--a", "help" => "un"],
|
||||
["-2", "--b", "help" => "deux"],
|
||||
],
|
||||
],
|
||||
["two", "help" => "blah blah",
|
||||
"cmd_args" => [
|
||||
["-3", "--c", "help" => "trois"],
|
||||
["-4", "--d", "help" => "quatre"],
|
||||
],
|
||||
],
|
||||
|
||||
"sections" => [
|
||||
[
|
||||
"title" => "section 1",
|
||||
["-s", "--shared", "help" => "option partagée"],
|
||||
["three", "help" => "blah blah blah",
|
||||
"cmd_args" => [
|
||||
["-5", "--e", "help" => "cinq"],
|
||||
["-6", "--f", "help" => "six"],
|
||||
],
|
||||
],
|
||||
["four", "help" => "blah blah blah blah",
|
||||
"cmd_args" => [
|
||||
["-7", "--g", "help" => "sept"],
|
||||
["-8", "--h", "help" => "huit"],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
private $args;
|
||||
private $command;
|
||||
private $common, $a, $b, $c, $d, $shared, $e, $f, $g, $h;
|
||||
|
||||
function main() {
|
||||
out::pnl("options", var_export([
|
||||
"common" => $this->common,
|
||||
"a" => $this->a,
|
||||
"b" => $this->b,
|
||||
"c" => $this->c,
|
||||
"d" => $this->d,
|
||||
"shared" => $this->shared,
|
||||
"e" => $this->e,
|
||||
"f" => $this->f,
|
||||
"g" => $this->g,
|
||||
"h" => $this->h,
|
||||
], true));
|
||||
out::pnl("args", var_export($this->args, true));
|
||||
out::pnl("command", var_export($this->command, true));
|
||||
}
|
||||
});
|
||||
37
nur_tbin/test-args2.php
Normal file
37
nur_tbin/test-args2.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\cli\Application;
|
||||
use nur\msg;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS = [
|
||||
"merge" => Application::ARGS,
|
||||
["-o", "args" => ["value", null], "name" => "option"],
|
||||
["args" => ["value"], "name" => "args"],
|
||||
# ["args" => ["value", "value"], "name" => "args"],
|
||||
# ["args" => ["value", ["value"]], "name" => "args"],
|
||||
# ["args" => ["value", null], "name" => "args"],
|
||||
];
|
||||
|
||||
private $option, $args;
|
||||
|
||||
function main() {
|
||||
Txx("option", $this->option);
|
||||
Txx("args", $this->args);
|
||||
|
||||
msg::group("prefix1", 1);
|
||||
msg::failure("aie1");
|
||||
msg::end();
|
||||
|
||||
msg::group("prefix2", 2);
|
||||
msg::failure("aie21");
|
||||
msg::failure("aie22");
|
||||
msg::end();
|
||||
|
||||
msg::group("hidden by default", null, msg::MINOR);
|
||||
msg::failure("aie31");
|
||||
msg::failure("aie32");
|
||||
msg::end();
|
||||
}
|
||||
});
|
||||
56
nur_tbin/test-args3.php
Normal file
56
nur_tbin/test-args3.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\cli\Application;
|
||||
use nur\cli\DynamicCommand;
|
||||
|
||||
class Test3DynamicCommand extends DynamicCommand {
|
||||
const COMMANDS = [
|
||||
"dyn1" => ["d1",
|
||||
"help" => "dynamic command 1",
|
||||
"cmd_args" => [
|
||||
["-o", "--d1-option"],
|
||||
["-v:", "--d1-value"],
|
||||
],
|
||||
],
|
||||
"dyn2" => ["d2",
|
||||
"help" => "dynamic command 2",
|
||||
"cmd_args" => [
|
||||
["-o", "--d2-option"],
|
||||
["-v:", "--d2-value"],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS = [
|
||||
#"dynamic_command" => [self::class, "get_dynamic_command"],
|
||||
"dynamic_command" => Test3DynamicCommand::class,
|
||||
["-o", "--option"],
|
||||
["-v:", "--value"],
|
||||
["static", "s",
|
||||
"help" => "static command",
|
||||
"cmd_args" => [
|
||||
["-o", "--s-option"],
|
||||
["-v:", "--s-value"],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
static function get_dynamic_command(string $command): ?array {
|
||||
switch ($command) {
|
||||
case "d1": return Test3DynamicCommand::COMMANDS["d1"];
|
||||
case "d2": return Test3DynamicCommand::COMMANDS["d2"];
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
private $option, $value, $args, $command;
|
||||
|
||||
function main() {
|
||||
Txx("option", $this->option, "value", $this->value);
|
||||
Txx("args", $this->args);
|
||||
Txx("command", $this->command);
|
||||
}
|
||||
});
|
||||
93
nur_tbin/test-conn.php
Normal file
93
nur_tbin/test-conn.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
# fichier utilisé pour les tests. on peut y écrire du code pour vérifier le
|
||||
# fonctionnement de certaines classes et méthodes
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\cli\Application;
|
||||
use nur\m\oracle\OracleConn;
|
||||
use nur\m\pdo\mysql\MysqlConn;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS = [
|
||||
"merge" => Application::ARGS,
|
||||
["--debug", "action" => "->setApplicationDebug",
|
||||
"help" => "Activer le mode DEBUG: comme VERBOSE mais les traceback sont affichés à partir des messages normaux",
|
||||
],
|
||||
["-0", "--init"],
|
||||
["-t", "--throw"],
|
||||
];
|
||||
|
||||
private $init, $throw;
|
||||
|
||||
private $args;
|
||||
|
||||
function main() {
|
||||
$this->testOracle();
|
||||
#$this->testMysql();
|
||||
#$this->testPgsql();
|
||||
}
|
||||
|
||||
function testOracle(): void {
|
||||
$conn = new OracleConn("//vs-apotest-bdd.univ.run:1521/apotest", "webread", "run974");
|
||||
|
||||
$q = $conn->query("select * from individu where cod_etu = :cod_etu", ["cod_etu" => "99002956"]);
|
||||
foreach ($q->execute() as $row) {
|
||||
Txx($row);
|
||||
}
|
||||
}
|
||||
|
||||
function testMysql(): void {
|
||||
#$conn = new MysqlConn("mysql:host=localhost;dbname=test;charset=utf8", "jclain");
|
||||
$conn = new MysqlConn("mysql:host=192.168.1.20;dbname=test;charset=utf8", "jclain", 'klokis$');
|
||||
|
||||
if ($this->init) {
|
||||
$conn->execDml("drop table if exists t");
|
||||
$conn->execDml("create table t(id integer not null primary key auto_increment, a varchar(30), b integer, d date, t timestamp default current_timestamp)");
|
||||
Txx($conn->execDml("insert into t(a, b) values ('first', 1)"));
|
||||
Txx($conn->execDml("insert into t(a, b, d) values ('second', 2, '2020-10-20')"));
|
||||
Txx($conn->execDml("insert into t(a, b, d) values ('second', 2, '2020-05-15')"));
|
||||
if ($this->throw) {
|
||||
Txx($conn->execDml("insert into t(id, a, b) values (2, 'conflict', 3)"));
|
||||
}
|
||||
$conn->commit();
|
||||
}
|
||||
|
||||
$do = 2;
|
||||
if ($do == 0) {
|
||||
$row = $conn->fetchRow("select a, b from t where b = 1");
|
||||
Txx("b==1", $row);
|
||||
|
||||
$row = $conn->fetchRow("select a, b from t where b = 100");
|
||||
Txx("b==100", $row);
|
||||
|
||||
$rows = $conn->fetchRows("select a, b from t");
|
||||
Txx("all", $rows);
|
||||
|
||||
$rows = $conn->fetchRows("select a, b from t where b > 100");
|
||||
Txx("all b>100", $rows);
|
||||
}
|
||||
|
||||
if ($do == 1) {
|
||||
$rows = $conn->fetchRows("select * from t");
|
||||
foreach ($rows as $row) {
|
||||
Txx("row", $row);
|
||||
}
|
||||
}
|
||||
|
||||
if ($do == 2) {
|
||||
$rows = $conn->query("select * from t")->execute();
|
||||
foreach ($rows as $row) {
|
||||
Txx("row", $row);
|
||||
}
|
||||
}
|
||||
|
||||
if ($do == 4) {
|
||||
$q = $conn->query("select * from t where d > :date");
|
||||
Txx("after 01/01", $q->execute(false, ["date" => "01/01/2020"])->all());
|
||||
Txx("after 15/06", $q->execute(false, ["date" => "15/06/2020"])->all());
|
||||
}
|
||||
}
|
||||
|
||||
function testPgsql(): void {
|
||||
}
|
||||
});
|
||||
13
nur_tbin/test-log.php
Normal file
13
nur_tbin/test-log.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\cli\Application;
|
||||
use nur\log;
|
||||
use nur\msg;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
function main() {
|
||||
msg::info("message affiché");
|
||||
log::info("message journalisé");
|
||||
}
|
||||
});
|
||||
285
nur_tbin/test-misc.php
Normal file
285
nur_tbin/test-misc.php
Normal file
@@ -0,0 +1,285 @@
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
# fichier utilisé pour les tests. on peut y écrire du code pour vérifier le
|
||||
# fonctionnement de certaines classes et méthodes
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\b\proc\AbstractCmd;
|
||||
use nur\b\proc\Cmd;
|
||||
use nur\b\proc\CmdAnd;
|
||||
use nur\b\proc\CmdOr;
|
||||
use nur\b\proc\CmdPipe;
|
||||
use nur\cli\Application;
|
||||
use nur\msg;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS1 = [
|
||||
"purpose" => "démontrer l'utilisation de ArgsParser",
|
||||
|
||||
["-a", "name" => "count", "help" => "Ajouter 1 au compteur"],
|
||||
["-z", "name" => "count", "inverse" => true, "help" => "Retrancher 1 au compteur"],
|
||||
["action1", "help" => "déclencher l'action n°1"],
|
||||
|
||||
"sections" => [
|
||||
[
|
||||
"title" => "Gestion des valeurs",
|
||||
["-v", "name" => "fixed_value", "value" => 42, "help" => "Fixer la valeur à 42"],
|
||||
["-s", "--set", "arg" => "value", "name" => "value", "help" => "Spécifier la valeur"],
|
||||
["-d", "--destdir", "arg" => "path", "help" => "Spécifier le répertoire de destination"],
|
||||
["-h", "--host", "arg" => "host", "help" => "Spécifier l'hôte sur lequel se connecter"],
|
||||
["--inc", "action" => "--inc", "help" => "Ajouter 1 à la valeur"],
|
||||
["--dec", "action" => "--dec", "help" => "Enlever 1 à la valeur"],
|
||||
["--set", "arg" => "value", "action" => "--set", "help" => "Spécifier la valeur"],
|
||||
["--add", "arg" => "value", "action" => "--add", "help" => "Ajouter une valeur au tableau"],
|
||||
["--fix", "action" => "--set", "value" => 53, "help" => "Fixer la valeur à 53"],
|
||||
],
|
||||
[
|
||||
"title" => "Arguments obligatoires et optionnels",
|
||||
["--mm", "args" => ["value", "value"]],
|
||||
["--mo", "args" => ["value", ["value"]]],
|
||||
["--oo", "args" => [["value", "value"]]],
|
||||
["--many", "args" => ["value", null]],
|
||||
["--any", "args" => [null]],
|
||||
["--mooany", "args" => ["value", ["value", "value", null]]],
|
||||
],
|
||||
[
|
||||
"title" => "Actions",
|
||||
["--honk", "action" => [self::class, "honk"], "help" => "Activer le klaxon"],
|
||||
["--pouet", "action" => "->pouet", "help" => "Activer le klaxon"],
|
||||
["--x2", "arg" => "value", "action" => "->x2",
|
||||
"help" => "Multiplier la valeur par 2"]
|
||||
],
|
||||
[
|
||||
"title" => "test Override",
|
||||
["-x", "--longx1", "help" => "l'option -x ne devrait pas apparaitre ici parce qu'elle est réutilisée"],
|
||||
["-x", "--longx2", "help" => "l'option -x devrait apparaitre ici"],
|
||||
["action2", "help" => "déclencher l'action n°2"],
|
||||
],
|
||||
[
|
||||
"title" => "test Group",
|
||||
["group",
|
||||
["--profile", "args" => "value", "name" => "profile",
|
||||
"help" => "spécifier le profil",
|
||||
],
|
||||
["-P", "--prod", "name" => "profile", "value" => "prod",
|
||||
"help" => "alias pour --profile prod",
|
||||
],
|
||||
["-T", "--test", "name" => "profile", "value" => "test",
|
||||
"help" => "alias pour --profile test",
|
||||
],
|
||||
["--devel", "name" => "profile", "value" => "devel",
|
||||
"help" => "alias pour --profile devel",
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
private $count = 0;
|
||||
private $value;
|
||||
private $fixed_value;
|
||||
private $destdir;
|
||||
private $host;
|
||||
private $inc;
|
||||
private $dec = 100;
|
||||
private $set;
|
||||
private $add;
|
||||
private $fix;
|
||||
private $mm, $mo, $oo, $many, $any, $mooany;
|
||||
private $profile;
|
||||
function run1() {
|
||||
Txx("Hello!");
|
||||
Txx("count:", $this->count);
|
||||
Txx("value:", $this->value);
|
||||
Txx("fixed_value:", $this->fixed_value);
|
||||
Txx("destdir:", $this->destdir);
|
||||
Txx("host:", $this->host);
|
||||
Txx("--inc:", $this->inc);
|
||||
Txx("--dec:", $this->dec);
|
||||
Txx("--set:", $this->set);
|
||||
Txx("--add:", $this->add);
|
||||
Txx("--fix:", $this->fix);
|
||||
Txx("mm", $this->mm);
|
||||
Txx("mo", $this->mo);
|
||||
Txx("oo", $this->oo);
|
||||
Txx("many", $this->many);
|
||||
Txx("any", $this->any);
|
||||
Txx("mooany", $this->mooany);
|
||||
Txx("profile", $this->profile);
|
||||
Txx("args:", $this->args);
|
||||
}
|
||||
static function honk() {
|
||||
echo "honk honk!\n";
|
||||
}
|
||||
function pouet() {
|
||||
echo "pouet pouet!\n";
|
||||
}
|
||||
function x2($value) {
|
||||
$double = $value * 2;
|
||||
echo "$value * 2 = $double\n";
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
|
||||
const ARGS2 = [
|
||||
["-a", "help" => "option courte sans argument"],
|
||||
["-b", "args" => "value", "help" => "option courte avec argument"],
|
||||
["-al1", "help" => "option longue sans argument"],
|
||||
["-bl1", "args" => "value", "help" => "option longue avec argument"],
|
||||
["--al2", "help" => "option longue sans argument"],
|
||||
["--bl2", "args" => "value", "help" => "option longue avec argument"],
|
||||
["ac", "action" => "->doAc", "help" => "commande sans argument"],
|
||||
["bc", "action" => "->doBc", "args" => "value", "help" => "commande avec argument"],
|
||||
|
||||
["c", "type" => "option", "help" => "option sans tiret"],
|
||||
["d", "type" => "option", "args" => "value", "help" => "option sans tiret avec argument"],
|
||||
|
||||
["-e", "type" => "command", "action" => "->doE", "help" => "commande courte tiret simple sans argument"],
|
||||
["-f", "type" => "command", "action" => "->doF", "args" => "value", "help" => "commande courte tiret simple avec argument"],
|
||||
["-ec1", "type" => "command", "action" => "->doEc1", "help" => "commande longue tiret simple sans argument"],
|
||||
["-fc1", "type" => "command", "action" => "->doFc1", "args" => "value", "help" => "commande longue tiret simple avec argument"],
|
||||
["--ec2", "type" => "command", "action" => "->doEc2", "help" => "commande longue tiret double sans argument"],
|
||||
["--fc2", "type" => "command", "action" => "->doFc2", "args" => "value", "help" => "commande longue tiret double avec argument"],
|
||||
];
|
||||
private $a, $b, $al1, $bl1, $al2, $bl2, $ac, $bc;
|
||||
private $c, $d;
|
||||
private $e, $f, $ec1, $fc1, $ec2, $fc2;
|
||||
function run2() {
|
||||
msg::section("option et commandes classiques");
|
||||
Txx("a", $this->a);
|
||||
Txx("b", $this->b);
|
||||
Txx("al1", $this->al1);
|
||||
Txx("bl1", $this->bl1);
|
||||
Txx("al2", $this->al2);
|
||||
Txx("bl2", $this->bl2);
|
||||
Txx("ac", $this->ac);
|
||||
Txx("bc", $this->bc);
|
||||
msg::section("options sans tiret");
|
||||
Txx("c", $this->c);
|
||||
Txx("d", $this->d);
|
||||
msg::section("commandes avec tiret");
|
||||
Txx("e", $this->e);
|
||||
Txx("f", $this->f);
|
||||
Txx("ec1", $this->ec1);
|
||||
Txx("fc1", $this->fc1);
|
||||
Txx("ec2", $this->ec2);
|
||||
Txx("fc2", $this->fc2);
|
||||
}
|
||||
function doAc($value, $name, $arg) {
|
||||
Txx("ac!", "value", $value, "name", $name, "arg", $arg, "def");
|
||||
$this->ac = 1;
|
||||
}
|
||||
function doBc($value, $name, $arg) {
|
||||
Txx("bc!", "value", $value, "name", $name, "arg", $arg, "def");
|
||||
$this->bc = $value;
|
||||
}
|
||||
function doE($value, $name, $arg) {
|
||||
Txx("e!", "value", $value, "name", $name, "arg", $arg, "def");
|
||||
$this->e = 1;
|
||||
}
|
||||
function doF($value, $name, $arg) {
|
||||
Txx("f!", "value", $value, "name", $name, "arg", $arg, "def");
|
||||
$this->f = $value;
|
||||
}
|
||||
function doEc1($value, $name, $arg) {
|
||||
Txx("ec1!", "value", $value, "name", $name, "arg", $arg, "def");
|
||||
$this->ec1 = 1;
|
||||
}
|
||||
function doFc1($value, $name, $arg) {
|
||||
Txx("fc1!", "value", $value, "name", $name, "arg", $arg, "def");
|
||||
$this->fc1 = $value;
|
||||
}
|
||||
function doEc2($value, $name, $arg) {
|
||||
Txx("ec2!", "value", $value, "name", $name, "arg", $arg, "def");
|
||||
$this->ec2 = 1;
|
||||
}
|
||||
function doFc2($value, $name, $arg) {
|
||||
Txx("fc2!", "value", $value, "name", $name, "arg", $arg, "def");
|
||||
$this->fc2 = $value;
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
|
||||
const ARGS3 = [
|
||||
["--cc", "name" => "cmdClass", "value" => Cmd::class],
|
||||
["--ca", "name" => "cmdClass", "value" => CmdAnd::class],
|
||||
["--co", "name" => "cmdClass", "value" => CmdOr::class],
|
||||
["--cp", "name" => "cmdClass", "value" => CmdPipe::class],
|
||||
["-v", "--var", "args" => "value", "action" => "->addVar"],
|
||||
["-V", "--lvar", "args" => "value", "action" => "->addLvar"],
|
||||
["-a", "--add", "args" => "value", "action" => "->addCmd"],
|
||||
["-A", "--ladd", "args" => "value", "action" => "->addLcmd"],
|
||||
["-p", "--prefix", "args" => "value", "action" => "->addPrefix"],
|
||||
["--xp", "name" => "action", "value" => "passthru"],
|
||||
["--xs", "name" => "action", "value" => "system"],
|
||||
["--xx", "name" => "action", "value" => "exec"],
|
||||
["--xf", "name" => "action", "value" => "fork_exec"],
|
||||
];
|
||||
private $cmdClass = Cmd::class;
|
||||
private $cmd;
|
||||
private function cmd(): AbstractCmd {
|
||||
if ($this->cmd === null) $this->cmd = new $this->cmdClass();
|
||||
return $this->cmd;
|
||||
}
|
||||
private $vars;
|
||||
function addVar($var) {
|
||||
[$name, $value] = explode("=", $var);
|
||||
$this->cmd()->addVars([$name => $value]);
|
||||
}
|
||||
function addLvar($var) {
|
||||
$this->cmd()->addLiteralVars($var);
|
||||
}
|
||||
private $cmds;
|
||||
function addCmd($cmd) {
|
||||
$this->cmd()->add($cmd);
|
||||
}
|
||||
function addLcmd($cmd) {
|
||||
$this->cmd()->addLiteral($cmd);
|
||||
}
|
||||
function addPrefix($prefix) {
|
||||
$this->cmd()->addPrefix($prefix);
|
||||
}
|
||||
private $action;
|
||||
|
||||
function run3() {
|
||||
$cmd = $this->cmd();
|
||||
msg::info("command: |\n".$cmd->getCmd()."\n|");
|
||||
switch ($this->action) {
|
||||
case "passthru":
|
||||
msg::section("passthru");
|
||||
$cmd->passthru($retcode);
|
||||
msg::info("retcode=$retcode");
|
||||
break;
|
||||
case "system":
|
||||
msg::section("system");
|
||||
$cmd->system($output,$retcode);
|
||||
$output = var_export($output, true);
|
||||
msg::info("output=|$output|, retcode=$retcode");
|
||||
break;
|
||||
case "exec":
|
||||
msg::section("exec");
|
||||
$cmd->exec($output, $retcode);
|
||||
$output = var_export($output, true);
|
||||
msg::info("output=|$output|, retcode=$retcode");
|
||||
break;
|
||||
case "fork_exec":
|
||||
msg::section("fork_exec");
|
||||
$cmd->fork_exec($retcode);
|
||||
msg::info("retcode=$retcode");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
|
||||
const ARGS = self::ARGS1;
|
||||
private $args;
|
||||
|
||||
function main() {
|
||||
if (self::ARGS === self::ARGS1) {
|
||||
$this->run1();
|
||||
} elseif (self::ARGS === self::ARGS2) {
|
||||
$this->run2();
|
||||
} elseif (self::ARGS === self::ARGS3) {
|
||||
$this->run3();
|
||||
}
|
||||
}
|
||||
});
|
||||
160
nur_tbin/test-msg.php
Normal file
160
nur_tbin/test-msg.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\A;
|
||||
use nur\b\UserException;
|
||||
use nur\cli\Application;
|
||||
use nur\config;
|
||||
use nur\msg;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
const ARGS = [
|
||||
"merge" => Application::ARGS,
|
||||
["-l:", "--level"],
|
||||
["-t:", "--type"],
|
||||
["-r:", "--result"],
|
||||
["-s:", "--suite"],
|
||||
];
|
||||
private $args;
|
||||
private $level, $type, $result, $suite, $noColor;
|
||||
|
||||
const LEVEL_MAP = [
|
||||
"1" => msg::CRITICAL, "c" => msg::CRITICAL,
|
||||
"2" => msg::MAJOR, "M" => msg::MAJOR,
|
||||
"3" => msg::NORMAL, "n" => msg::NORMAL,
|
||||
"4" => msg::MINOR, "m" => msg::MINOR,
|
||||
];
|
||||
const TYPE_MAP = [
|
||||
"1" => msg::ERROR, "e" => msg::ERROR,
|
||||
"2" => msg::WARNING, "w" => msg::WARNING,
|
||||
"3" => msg::INFO, "i" => msg::INFO,
|
||||
"4" => msg::DEBUG, "d" => msg::DEBUG,
|
||||
];
|
||||
const RESULT_MAP = [
|
||||
"0" => msg::NONE, "n" => msg::NONE,
|
||||
"1" => msg::NEUTRAL, "s" => msg::NEUTRAL,
|
||||
"2" => msg::SUCCESS, "ok" => msg::SUCCESS,
|
||||
"3" => msg::FAILURE, "ko" => msg::FAILURE,
|
||||
];
|
||||
|
||||
const LEVELS = [
|
||||
msg::CRITICAL => "critical",
|
||||
msg::MAJOR => "major",
|
||||
msg::NORMAL => "normal",
|
||||
msg::MINOR => "minor",
|
||||
];
|
||||
|
||||
const TYPES = [
|
||||
msg::ERROR => "error",
|
||||
msg::WARNING => "warning",
|
||||
msg::INFO => "info",
|
||||
msg::DEBUG => "debug",
|
||||
];
|
||||
|
||||
const RESULTS = [msg::NONE, msg::NEUTRAL, msg::SUCCESS, msg::FAILURE];
|
||||
|
||||
function main() {
|
||||
msg::info("current profile is " . config::get_profile());
|
||||
|
||||
$level = A::get(self::LEVEL_MAP, $this->level);
|
||||
$levels = A::with($level);
|
||||
if (!$levels) $levels = array_keys(self::LEVELS);
|
||||
|
||||
$type = A::get(self::TYPE_MAP, $this->type);
|
||||
$types = A::with($type);
|
||||
if (!$types) $types = array_keys(self::TYPES);
|
||||
|
||||
$result = A::get(self::RESULT_MAP, $this->result);
|
||||
$results = A::with($result);
|
||||
if (!$results) $results = self::RESULTS;
|
||||
|
||||
$suite = $this->suite;
|
||||
|
||||
$msg = msg::get();
|
||||
foreach (self::LEVELS as $level => $levelName) {
|
||||
if (!in_array($level, $levels)) continue;
|
||||
|
||||
if ($suite === null || $suite == "1") {
|
||||
msg::section("$levelName messages -- user only", $level, msg::INFO);
|
||||
foreach (self::TYPES as $type => $typeName) {
|
||||
if (!in_array($type, $types)) continue;
|
||||
foreach ($results as $result) {
|
||||
$msg->addMessage("user only $levelName $typeName", $type + $result, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($suite === null || $suite == "2") {
|
||||
msg::section("$levelName messages -- user + tech", $level, msg::INFO);
|
||||
foreach (self::TYPES as $type => $typeName) {
|
||||
if (!in_array($type, $types)) continue;
|
||||
foreach ($results as $result) {
|
||||
$msg->addMessage([
|
||||
"user $levelName $typeName",
|
||||
"tech $levelName $typeName",
|
||||
], $type + $result, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($suite === null || $suite == "3") {
|
||||
msg::section("$levelName messages -- UserException", $level, msg::INFO);
|
||||
$e = new UserException(["e_user", "e_tech"]);
|
||||
foreach (self::TYPES as $type => $typeName) {
|
||||
if (!in_array($type, $types)) continue;
|
||||
foreach ($results as $result) {
|
||||
$msg->addMessage($e, $type + $result, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($suite === null || $suite == "4") {
|
||||
msg::section("$levelName messages -- Exception", $level, msg::INFO);
|
||||
$e = new Exception("e_message");
|
||||
foreach (self::TYPES as $type => $typeName) {
|
||||
if (!in_array($type, $types)) continue;
|
||||
foreach ($results as $result) {
|
||||
$msg->addMessage($e, $type + $result, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($suite === null || $suite == "5") {
|
||||
msg::section("$levelName messages -- user, Exception", $level, msg::INFO);
|
||||
$e = new Exception("e_message");
|
||||
foreach (self::TYPES as $type => $typeName) {
|
||||
if (!in_array($type, $types)) continue;
|
||||
foreach ($results as $result) {
|
||||
$msg->addMessage(["user", $e], $type + $result, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($suite === null || $suite == "6") {
|
||||
msg::section("$levelName messages -- user, tech, Exception", $level, msg::INFO);
|
||||
$e = new Exception("e_message");
|
||||
foreach (self::TYPES as $type => $typeName) {
|
||||
if (!in_array($type, $types)) continue;
|
||||
foreach ($results as $result) {
|
||||
$msg->addMessage(["user", "tech", $e], $type + $result, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($suite === null || $suite == "7") {
|
||||
msg::section("$levelName messages -- user, UserException", $level, msg::INFO);
|
||||
$e = new UserException(["e_user", "e_tech"]);
|
||||
foreach (self::TYPES as $type => $typeName) {
|
||||
if (!in_array($type, $types)) continue;
|
||||
foreach ($results as $result) {
|
||||
$msg->addMessage(["user", $e], $type + $result, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($suite === null || $suite == "8") {
|
||||
msg::section("$levelName messages -- user, tech, UserException", $level, msg::INFO);
|
||||
$e = new UserException(["e_user", "e_tech"]);
|
||||
foreach (self::TYPES as $type => $typeName) {
|
||||
if (!in_array($type, $types)) continue;
|
||||
foreach ($results as $result) {
|
||||
$msg->addMessage(["user", "tech", $e], $type + $result, $level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
14
nur_tbin/test-vanilla-app.php
Normal file
14
nur_tbin/test-vanilla-app.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php # -*- coding: utf-8 mode: php -*- vim:sw=2:sts=2:et:ai:si:sta:fenc=utf-8
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\cli\Application;
|
||||
use nur\msg;
|
||||
|
||||
Application::run(new class extends Application {
|
||||
private $args;
|
||||
|
||||
function main() {
|
||||
msg::info("Sélection du profil ".self::profile());
|
||||
Txx("args", $this->args);
|
||||
}
|
||||
});
|
||||
21
nur_tbin/update_classes.php
Executable file
21
nur_tbin/update_classes.php
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
require(__DIR__.'/../vendor/autoload.php');
|
||||
|
||||
use nur\b\coll\impl\ItemView;
|
||||
use nur\b\params\impl\MyParametrable;
|
||||
use nur\php\UpdateClassesApp;
|
||||
|
||||
UpdateClassesApp::run(new class extends UpdateClassesApp {
|
||||
const MAPPINGS = [
|
||||
"src_b" => [
|
||||
"package" => "nur\\",
|
||||
"path" => __DIR__."/../tests",
|
||||
"classes" => [
|
||||
ItemView::class,
|
||||
MyParametrable::class,
|
||||
],
|
||||
"allow_undefined" => true,
|
||||
],
|
||||
];
|
||||
});
|
||||
Reference in New Issue
Block a user