nur-sery/tbin/legacy-test-nested-actions.php

81 lines
1.8 KiB
PHP
Executable File

#!/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");
$msg->asuccess();
});
$msg->asuccess();
});
$msg->asuccess();
});
msg::action("first2", function (IMessenger $msg) {
msg::action("second2", function (IMessenger $msg) {
msg::action("third2", function (IMessenger $msg) {
$msg->info("hello world2");
$msg->asuccess();
});
$msg->asuccess();
});
$msg->asuccess();
});
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();
}
});