2024-05-16 17:51:05 +04:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
require(__DIR__.'/../vendor/autoload.php');
|
|
|
|
|
|
|
|
use nur\cli\Application;
|
|
|
|
use nur\sery\output\IMessenger;
|
|
|
|
use nur\sery\output\msg;
|
|
|
|
use nur\sery\UserException;
|
|
|
|
|
|
|
|
Application::run(new class extends Application {
|
|
|
|
function main() {
|
|
|
|
msg::section("ma section");
|
|
|
|
msg::action("first", function (IMessenger $msg) {
|
|
|
|
msg::action("second", function (IMessenger $msg) {
|
|
|
|
msg::action("third", function (IMessenger $msg) {
|
|
|
|
$msg->info("hello world");
|
2024-05-16 18:03:21 +04:00
|
|
|
$msg->asuccess();
|
2024-05-16 17:51:05 +04:00
|
|
|
});
|
|
|
|
$msg->asuccess();
|
|
|
|
});
|
2024-05-16 18:03:21 +04:00
|
|
|
$msg->asuccess();
|
2024-05-16 17:51:05 +04:00
|
|
|
});
|
|
|
|
msg::action("first2", function (IMessenger $msg) {
|
|
|
|
msg::action("second2", function (IMessenger $msg) {
|
|
|
|
msg::action("third2", function (IMessenger $msg) {
|
|
|
|
$msg->info("hello world2");
|
2024-05-16 18:03:21 +04:00
|
|
|
$msg->asuccess();
|
2024-05-16 17:51:05 +04:00
|
|
|
});
|
|
|
|
$msg->asuccess();
|
|
|
|
});
|
2024-05-16 18:03:21 +04:00
|
|
|
$msg->asuccess();
|
2024-05-16 17:51:05 +04:00
|
|
|
});
|
2024-05-22 15:33:19 +04:00
|
|
|
|
|
|
|
msg::title("auto result");
|
|
|
|
msg::action("sans result 1", function ($msg) {
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
msg::print("hello 1");
|
|
|
|
|
|
|
|
msg::action("sans result 2", function ($msg) {
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
msg::print("hello 2");
|
|
|
|
|
|
|
|
msg::action("sans result 3", function ($msg) {
|
|
|
|
return "whatever";
|
|
|
|
});
|
|
|
|
msg::print("hello 3");
|
|
|
|
|
|
|
|
try {
|
|
|
|
msg::action("sans result 4", function ($msg) {
|
|
|
|
throw new Exception();
|
|
|
|
});
|
|
|
|
} catch (Exception $e) {}
|
|
|
|
msg::print("hello 4");
|
|
|
|
|
|
|
|
msg::action("avec result 1", function ($msg) {
|
|
|
|
$msg->asuccess();
|
|
|
|
});
|
|
|
|
msg::print("hello 1");
|
|
|
|
|
|
|
|
msg::action("avec result 2", function ($msg) {
|
|
|
|
$msg->afailure();
|
|
|
|
});
|
|
|
|
msg::print("hello 2");
|
|
|
|
|
|
|
|
msg::action("avec result 3", function ($msg) {
|
|
|
|
$msg->adone();
|
|
|
|
});
|
|
|
|
msg::print("hello 3");
|
|
|
|
|
|
|
|
try {
|
|
|
|
msg::action("avec result 4", function ($msg) {
|
|
|
|
$msg->aresult(new Exception());
|
|
|
|
});
|
|
|
|
} catch (Exception $e) {}
|
|
|
|
msg::print("hello 4");
|
|
|
|
msg::end();
|
2024-05-16 17:51:05 +04:00
|
|
|
}
|
|
|
|
});
|