#!/usr/bin/php
<?php
require(__DIR__.'/../vendor/autoload.php');

use nur\sery\output\StdMessenger;

$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;
  case "-L":
    $i++;
    $params["output"] = $argv[$i];
    break;
  case "-D":
    $params["default_level"] = "debug";
    $params["debug"] = true;
    break;
  case "-N":
    $params["default_level"] = "normal";
    break;
  case "-M":
    $params["default_level"] = "major";
    break;
  }
}
$c = new StdMessenger($params);

$c->section("section");

$c->title("title");
$c->desc("desc");
$c->print("print");

$c->action("action");
$c->step("step");
$c->success("action success");

$c->action("action");
$c->step("step");
$c->failure("action failure");

$c->action("action");
$c->success("action success");

$c->action("action");
$c->failure("action failure");

$c->action("action0");
$c->action("action1");
$c->action("action2");
$c->success("action2 success");
$c->success("action1 success");
$c->success("action0 success");

$c->action("action");
$c->step("step");
$c->success();

$c->action("action");
$c->step("step");
$c->failure();

$c->action("action");
$c->success();

$c->action("action");
$c->failure();

$c->action("action0");
$c->action("action1");
$c->action("action2");
$c->success();
$c->success();
$c->success();

$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");
$c->info("multi-line\ninfo");
$c->action("multi-line\naction");
$c->success();
$c->action("multi-line\naction");
$c->step("multi-line\nstep");
$c->failure();
$c->action("multi-line\naction");
$c->step("multi-line\nstep");
$c->success("multi-line\nsuccess");
$c->end(true);
