2024-05-02 10:01:48 +04:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
require(__DIR__.'/../vendor/autoload.php');
|
|
|
|
|
|
|
|
use nur\cli\Application;
|
|
|
|
use nur\sery\output\msg;
|
|
|
|
use nur\sery\UserException;
|
|
|
|
|
|
|
|
Application::run(new class extends Application {
|
|
|
|
function main() {
|
|
|
|
msg::title("title0");
|
|
|
|
msg::title("title1");
|
|
|
|
msg::print("print under title1");
|
|
|
|
msg::end();
|
|
|
|
msg::print("print under title0");
|
|
|
|
msg::end();
|
|
|
|
|
|
|
|
msg::desc("action avec step");
|
|
|
|
msg::action("action avec step");
|
|
|
|
msg::step("step");
|
|
|
|
msg::asuccess("action success");
|
|
|
|
|
|
|
|
msg::action("action avec step");
|
|
|
|
msg::step("step");
|
|
|
|
msg::afailure("action failure");
|
|
|
|
|
|
|
|
msg::action("action avec step");
|
|
|
|
msg::step("step");
|
|
|
|
msg::adone("action neutral");
|
|
|
|
|
|
|
|
msg::desc("actions sans step");
|
|
|
|
msg::action("action sans step");
|
|
|
|
msg::asuccess("action success");
|
|
|
|
|
|
|
|
msg::action("action sans step");
|
|
|
|
msg::afailure("action failure");
|
|
|
|
|
|
|
|
msg::action("action sans step");
|
|
|
|
msg::adone("action neutral");
|
|
|
|
|
|
|
|
msg::desc("actions imbriquées");
|
|
|
|
msg::action("action0");
|
|
|
|
msg::action("action1");
|
|
|
|
msg::action("action2");
|
|
|
|
msg::asuccess("action2 success");
|
|
|
|
msg::asuccess("action1 success");
|
|
|
|
msg::asuccess("action0 success");
|
|
|
|
|
|
|
|
msg::desc("action avec step, sans messages");
|
|
|
|
msg::action("action avec step, sans messages, success");
|
|
|
|
msg::step("step");
|
|
|
|
msg::asuccess();
|
|
|
|
|
|
|
|
msg::action("action avec step, sans messages, failure");
|
|
|
|
msg::step("step");
|
|
|
|
msg::afailure();
|
|
|
|
|
|
|
|
msg::action("action avec step, sans messages, done");
|
|
|
|
msg::step("step");
|
|
|
|
msg::adone();
|
|
|
|
|
|
|
|
msg::desc("action sans step, sans messages");
|
|
|
|
msg::action("action sans step, sans messages, success");
|
|
|
|
msg::asuccess();
|
|
|
|
|
|
|
|
msg::action("action sans step, sans messages, failure");
|
|
|
|
msg::afailure();
|
|
|
|
|
|
|
|
msg::action("action sans step, sans messages, done");
|
|
|
|
msg::adone();
|
|
|
|
|
|
|
|
msg::desc("actions imbriquées, sans messages");
|
|
|
|
msg::action("action0");
|
|
|
|
msg::action("action1");
|
|
|
|
msg::action("action2");
|
|
|
|
msg::asuccess();
|
|
|
|
msg::asuccess();
|
|
|
|
msg::asuccess();
|
|
|
|
|
|
|
|
msg::info("info");
|
|
|
|
msg::note("note");
|
2024-05-16 09:42:00 +04:00
|
|
|
msg::warning("warning");
|
2024-05-02 10:01:48 +04:00
|
|
|
msg::error("error");
|
|
|
|
|
|
|
|
msg::section("section", function ($msg) {
|
|
|
|
$msg->title("title", function ($msg) {
|
|
|
|
$msg->desc("desc");
|
|
|
|
$msg->print("print");
|
|
|
|
|
|
|
|
$msg->desc("action avec step");
|
|
|
|
$msg->action("action avec step", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
$msg->asuccess("action success");
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action avec step", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
$msg->afailure("action failure");
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action avec step", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
$msg->adone("action done");
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->desc("actions sans step");
|
|
|
|
$msg->action("action sans step", function ($msg) {
|
|
|
|
$msg->asuccess("action success");
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action sans step", function ($msg) {
|
|
|
|
$msg->afailure("action failure");
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action sans step", function ($msg) {
|
|
|
|
$msg->adone("action done");
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->desc("actions imbriquées");
|
|
|
|
$msg->action("action0", function ($msg) {
|
|
|
|
$msg->action("action1", function ($msg) {
|
|
|
|
$msg->action("action2", function ($msg) {
|
|
|
|
$msg->asuccess("action2 success");
|
|
|
|
});
|
|
|
|
$msg->asuccess("action1 success");
|
|
|
|
});
|
|
|
|
$msg->asuccess("action0 success");
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->desc("action avec step, sans messages");
|
|
|
|
$msg->action("action avec step, sans messages, success", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
$msg->asuccess();
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action avec step, sans messages, failure", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
$msg->afailure();
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action avec step, sans messages, done", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
$msg->adone();
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->desc("action sans step, sans messages");
|
|
|
|
$msg->action("action sans step, sans messages, success", function ($msg) {
|
|
|
|
$msg->asuccess();
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action sans step, sans messages, failure", function ($msg) {
|
|
|
|
$msg->afailure();
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action sans step, sans messages, done", function ($msg) {
|
|
|
|
$msg->adone();
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->desc("actions imbriquées, sans messages");
|
|
|
|
$msg->action("action0", function ($msg) {
|
|
|
|
$msg->action("action1", function ($msg) {
|
|
|
|
$msg->action("action2", function ($msg) {
|
|
|
|
$msg->asuccess();
|
|
|
|
});
|
|
|
|
$msg->asuccess();
|
|
|
|
});
|
|
|
|
$msg->asuccess();
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->desc("action avec step, avec code de retour");
|
|
|
|
$msg->action("action avec step, avec code de retour true", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action avec step, avec code de retour false", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action avec step, avec code de retour autre", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
return "autre";
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action avec step, avec code de retour null", function ($msg) {
|
|
|
|
$msg->step("step");
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->desc("action sans step, avec code de retour");
|
|
|
|
$msg->action("action sans step, avec code de retour true", function ($msg) {
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action sans step, avec code de retour false", function ($msg) {
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->action("action sans step, avec code de retour autre", function ($msg) {
|
|
|
|
return "autre";
|
|
|
|
});
|
|
|
|
|
|
|
|
# ici, il n'y aura pas de message du tout
|
|
|
|
$msg->action("action sans step, avec code de retour null", function ($msg) {
|
|
|
|
});
|
|
|
|
|
|
|
|
$msg->info("info");
|
|
|
|
$msg->note("note");
|
2024-07-02 09:55:22 +04:00
|
|
|
$msg->warning("warning");
|
2024-05-02 10:01:48 +04:00
|
|
|
$msg->error("error");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
msg::section("multi-line\nsection", function ($msg) {
|
|
|
|
$msg->title("multi-line\ntitle");
|
|
|
|
$msg->title("another\ntitle");
|
|
|
|
|
|
|
|
$msg->print("multi-line\nprint");
|
|
|
|
$msg->info("multi-line\ninfo");
|
|
|
|
$msg->action("multi-line\naction");
|
|
|
|
$msg->asuccess();
|
|
|
|
$msg->action("multi-line\naction");
|
|
|
|
$msg->step("multi-line\nstep");
|
|
|
|
$msg->afailure();
|
|
|
|
$msg->action("multi-line\naction");
|
|
|
|
$msg->step("multi-line\nstep");
|
|
|
|
$msg->asuccess("multi-line\nsuccess");
|
|
|
|
$msg->action("multi-line\naction");
|
|
|
|
$msg->step("multi-line\nstep");
|
|
|
|
$msg->adone("multi-line\ndone");
|
|
|
|
|
|
|
|
$msg->end();
|
|
|
|
$msg->end();
|
|
|
|
});
|
|
|
|
|
|
|
|
msg::section("Exceptions", function ($msg) {
|
|
|
|
$e = new Exception("message");
|
2024-07-02 21:46:47 +04:00
|
|
|
$u1 = new UserException("userMessage1");
|
|
|
|
$u2 = new UserException("userMessage2", "techMessage2");
|
2024-05-02 10:01:48 +04:00
|
|
|
$msg->title("avec message", function ($msg) use ($e, $u1, $u2) {
|
2024-07-02 21:46:47 +04:00
|
|
|
$msg->info(["exception message", $e]);
|
|
|
|
$msg->info(["userException1 message", $u1]);
|
|
|
|
$msg->info(["userException2 message", $u2]);
|
2024-05-02 10:01:48 +04:00
|
|
|
});
|
|
|
|
$msg->title("sans message", function ($msg) use ($e, $u1, $u2) {
|
|
|
|
$msg->info($e);
|
|
|
|
$msg->info($u1);
|
|
|
|
$msg->info($u2);
|
|
|
|
});
|
|
|
|
});
|
2024-07-02 22:03:17 +04:00
|
|
|
|
|
|
|
msg::title("premier niveau");
|
|
|
|
msg::step("premier message");
|
|
|
|
msg::title("deuxieme niveau");
|
|
|
|
msg::step("deuxième message");
|
|
|
|
msg::title("troisième niveau");
|
|
|
|
msg::step("troisième message");
|
|
|
|
msg::action("action avec plusieurs failure", function ($msg) {
|
|
|
|
$msg->afailure("premier échec");
|
|
|
|
$msg->afailure("deuxième échec");
|
|
|
|
$msg->afailure("troisième échec");
|
|
|
|
});
|
|
|
|
msg::step("troisième conclusion");
|
|
|
|
msg::end();
|
|
|
|
msg::step("deuxième conclusion");
|
|
|
|
msg::end();
|
|
|
|
msg::step("première conclusion");
|
|
|
|
msg::end();
|
|
|
|
msg::step("conclusion");
|
2024-05-02 10:01:48 +04:00
|
|
|
}
|
|
|
|
});
|