modifs.mineures sans commentaires
This commit is contained in:
parent
7fb34f0276
commit
ad88b16a32
|
@ -5,6 +5,8 @@ use Exception;
|
|||
use nulib\cl;
|
||||
|
||||
class Console implements IMessenger {
|
||||
const INDENT = " ";
|
||||
|
||||
const VALID_LEVELS = [
|
||||
self::LEVEL_DEBUG,
|
||||
self::LEVEL_NORMAL,
|
||||
|
@ -70,10 +72,12 @@ class Console implements IMessenger {
|
|||
$this->out = new StdOutput(STDOUT);
|
||||
$this->err = new StdOutput(STDERR);
|
||||
$this->minLevel = intval($minLevel);
|
||||
$this->pending = [];
|
||||
$this->indent = static::INDENT;
|
||||
$this->inSection = false;
|
||||
$this->titles = null;
|
||||
$this->currentTitle = null;
|
||||
$this->actions = null;
|
||||
$this->currentAction = null;
|
||||
}
|
||||
|
||||
/** @var StdOutput la sortie standard */
|
||||
|
@ -85,6 +89,9 @@ class Console implements IMessenger {
|
|||
/** @var int level minimum que doivent avoir les messages pour être affichés */
|
||||
protected $minLevel;
|
||||
|
||||
/** @var string valeur unitaire de l'indentation */
|
||||
protected $indent;
|
||||
|
||||
/** @var bool est-on dans une section? */
|
||||
protected $inSection;
|
||||
|
||||
|
@ -139,16 +146,11 @@ class Console implements IMessenger {
|
|||
if ($this->titles) {
|
||||
$this->currentTitle =& $this->titles[count($this->titles) - 1];
|
||||
} else {
|
||||
$this->titles = null;
|
||||
unset($this->currentTitle);
|
||||
}
|
||||
}
|
||||
|
||||
function print($content, int $level=self::LEVEL_NORMAL): void {
|
||||
if ($level < $this->minLevel) return;
|
||||
$this->printTitles();
|
||||
$this->out->print($content);
|
||||
}
|
||||
|
||||
/** @var array */
|
||||
protected $actions;
|
||||
|
||||
|
@ -158,9 +160,11 @@ class Console implements IMessenger {
|
|||
function action($content, int $level=self::LEVEL_NORMAL): void {
|
||||
$this->actions[] = [
|
||||
"level" => $level,
|
||||
"contents" => [$content],
|
||||
"content" => $content,
|
||||
"print_content" => true,
|
||||
"success" => null,
|
||||
"result" => null,
|
||||
"print" => true,
|
||||
"print_result" => true,
|
||||
];
|
||||
$this->currentAction =& $this->actions[count($this->actions) - 1];
|
||||
}
|
||||
|
@ -171,26 +175,30 @@ class Console implements IMessenger {
|
|||
}
|
||||
|
||||
function step($content): void {
|
||||
if (!$this->actions) $this->action(null);
|
||||
$this->printActions();
|
||||
}
|
||||
|
||||
function success($content=null): void {
|
||||
$this->currentAction["contents"][] = $content;
|
||||
$this->currentAction["result"] = true;
|
||||
if (!$this->actions) $this->action(null);
|
||||
$this->currentAction["success"] = true;
|
||||
$this->currentAction["result"] = $content;
|
||||
$this->printActions();
|
||||
$this->endAction();
|
||||
}
|
||||
|
||||
function failure($content=null): void {
|
||||
$this->currentAction["contents"][] = $content;
|
||||
$this->currentAction["result"] = false;
|
||||
if (!$this->actions) $this->action(null);
|
||||
$this->currentAction["success"] = false;
|
||||
$this->currentAction["result"] = $content;
|
||||
$this->printActions();
|
||||
$this->endAction();
|
||||
}
|
||||
|
||||
function neutral($content=null): void {
|
||||
$this->currentAction["contents"][] = $content;
|
||||
$this->currentAction["result"] = null;
|
||||
if (!$this->actions) $this->action(null);
|
||||
$this->currentAction["success"] = null;
|
||||
$this->currentAction["result"] = $content;
|
||||
$this->printActions();
|
||||
$this->endAction();
|
||||
}
|
||||
|
@ -200,10 +208,17 @@ class Console implements IMessenger {
|
|||
if ($this->actions) {
|
||||
$this->currentAction =& $this->actions[count($this->actions) - 1];
|
||||
} else {
|
||||
$this->actions = null;
|
||||
unset($this->currentAction);
|
||||
}
|
||||
}
|
||||
|
||||
function print($content, int $level=self::LEVEL_NORMAL): void {
|
||||
if ($level < $this->minLevel) return;
|
||||
$this->printActions();
|
||||
$this->out->print($content);
|
||||
}
|
||||
|
||||
function info($content, int $level=self::LEVEL_NORMAL): void {
|
||||
if ($level < $this->minLevel) return;
|
||||
$this->printActions();
|
||||
|
|
|
@ -26,9 +26,6 @@ interface IMessenger {
|
|||
/** ajouter une description au chapitre courant. */
|
||||
function desc($content, int $level=self::LEVEL_NORMAL): void;
|
||||
|
||||
/** afficher une donnée non structurée dans la chapitre courant */
|
||||
function print($content, int $level=self::LEVEL_NORMAL): void;
|
||||
|
||||
/**
|
||||
* comencer une action dans le chapitre courant.
|
||||
*
|
||||
|
@ -64,6 +61,9 @@ interface IMessenger {
|
|||
*/
|
||||
function neutral($content=null): void;
|
||||
|
||||
/** afficher une donnée non structurée */
|
||||
function print($content, int $level=self::LEVEL_NORMAL): void;
|
||||
|
||||
/** ajouter un événément "information" */
|
||||
function info($content, int $level=self::LEVEL_NORMAL): void;
|
||||
|
||||
|
|
Loading…
Reference in New Issue