nur-sery/tbin/test-console.php

160 lines
3.1 KiB
PHP
Raw Normal View History

2023-12-26 23:27:51 +04:00
#!/usr/bin/php
<?php
require(__DIR__.'/../vendor/autoload.php');
2023-12-28 13:29:39 +04:00
use nulib\UserException;
2023-12-27 11:38:43 +04:00
use nur\sery\output\std\StdMessenger;
2023-12-26 23:27:51 +04:00
$params = [];
$count = count($argv) - 1;
for ($i = 1; $i <= $count; $i++) {
switch ($argv[$i]) {
case "-n":
$params["color"] = false;
break;
case "+n":
$params["color"] = true;
break;
case "-d":
$params["debug"] = true;
break;
case "+d":
$params["debug"] = false;
break;
2023-12-27 01:39:08 +04:00
case "-L":
$i++;
$params["output"] = $argv[$i];
break;
2023-12-26 23:27:51 +04:00
case "-D":
$params["default_level"] = "debug";
$params["debug"] = true;
break;
case "-N":
$params["default_level"] = "normal";
break;
case "-M":
$params["default_level"] = "major";
break;
2023-12-28 11:54:15 +04:00
case "-i":
$i++;
$params["id"] = $argv[$i];
break;
case "-t":
$params["add_date"] = true;
break;
2023-12-26 23:27:51 +04:00
}
}
2023-12-27 01:39:08 +04:00
$c = new StdMessenger($params);
2023-12-26 23:27:51 +04:00
$c->section("section");
$c->title("title");
$c->desc("desc");
$c->print("print");
$c->action("action");
$c->step("step");
2023-12-27 11:38:43 +04:00
$c->asuccess("action success");
2023-12-26 23:27:51 +04:00
$c->action("action");
$c->step("step");
2023-12-27 11:38:43 +04:00
$c->afailure("action failure");
2023-12-26 23:27:51 +04:00
$c->action("action");
2023-12-27 11:38:43 +04:00
$c->step("step");
$c->adone("action neutral");
$c->action("action");
$c->asuccess("action success");
2023-12-26 23:27:51 +04:00
$c->action("action");
2023-12-27 11:38:43 +04:00
$c->afailure("action failure");
$c->action("action");
$c->adone("action neutral");
2023-12-26 23:27:51 +04:00
$c->action("action0");
$c->action("action1");
$c->action("action2");
2023-12-27 11:38:43 +04:00
$c->asuccess("action2 success");
$c->asuccess("action1 success");
$c->asuccess("action0 success");
$c->action("action");
$c->step("step");
$c->asuccess();
2023-12-26 23:27:51 +04:00
2023-12-27 00:34:59 +04:00
$c->action("action");
$c->step("step");
2023-12-27 11:38:43 +04:00
$c->afailure();
2023-12-27 00:34:59 +04:00
$c->action("action");
$c->step("step");
2023-12-27 11:38:43 +04:00
$c->adone();
$c->action("action");
$c->asuccess();
2023-12-27 00:34:59 +04:00
$c->action("action");
2023-12-27 11:38:43 +04:00
$c->afailure();
2023-12-27 00:34:59 +04:00
$c->action("action");
2023-12-27 11:38:43 +04:00
$c->adone();
2023-12-27 00:34:59 +04:00
$c->action("action0");
$c->action("action1");
$c->action("action2");
2023-12-27 11:38:43 +04:00
$c->asuccess();
$c->asuccess();
$c->asuccess();
2023-12-27 00:34:59 +04:00
2023-12-26 23:27:51 +04:00
$c->info("info");
$c->note("note");
$c->warn("warn");
$c->error("error");
$c->end();
$c->title("title0");
$c->title("title1");
$c->print("print under title1");
$c->end();
$c->print("print under title0");
$c->end();
$c->end(true);
$c->section("multi-line\nsection");
$c->title("multi-line\ntitle");
$c->title("another\ntitle");
$c->print("multi-line\nprint");
2023-12-27 01:39:08 +04:00
$c->info("multi-line\ninfo");
$c->action("multi-line\naction");
2023-12-27 11:38:43 +04:00
$c->asuccess();
$c->action("multi-line\naction");
$c->step("multi-line\nstep");
$c->afailure();
2023-12-27 01:39:08 +04:00
$c->action("multi-line\naction");
$c->step("multi-line\nstep");
2023-12-27 11:38:43 +04:00
$c->asuccess("multi-line\nsuccess");
2023-12-27 01:39:08 +04:00
$c->action("multi-line\naction");
$c->step("multi-line\nstep");
2023-12-27 11:38:43 +04:00
$c->adone("multi-line\ndone");
2023-12-26 23:27:51 +04:00
$c->end(true);
2023-12-28 13:29:39 +04:00
$exception = new Exception("message");
$userException1 = new UserException("userMessage");
$userException2 = new UserException("userMessage", "techMessage");
$c->section("Exceptions");
$c->title("avec message");
$c->info(["exception", $exception]);
$c->info(["userException1", $userException1]);
$c->info(["userException2", $userException2]);
$c->end();
$c->title("sans message");
$c->info($exception);
$c->info($userException1);
$c->info($userException2);
$c->end();