Input / Output

The Centum\Console\Terminal makes it easy to interact with the Terminal, both in terms of input and output. By default, it reads and writes to STDIN, STDOUT, and STDERR.

Centum\Console\Terminal(
    Centum\Interfaces\Console\Terminal\ArgumentsInterface $arguments,
    resource $stdin = STDIN,
    resource $stdout = STDOUT,
    resource $stderr = STDERR
);

Centum\Console\Terminal implements Centum\Interfaces\Console\TerminalInterface.

use Centum\Console\Terminal;
use Centum\Interfaces\Console\Terminal\ArgumentsInterface;

/** @var ArgumentsInterface $arguments */

$terminal = new Terminal($arguments);

Input

Getting the Arguments

$arguments = $terminal->getArguments();

Output

Writing to the Terminal

(to STDOUT)

$terminal->write("hello");
$terminal->writeLine("hello");

Error messages

(to STDERR)

$terminal->writeError("hello");
$terminal->writeErrorLine("hello");

Displaying a list

$terminal->writeList(
    [
        "Item 1",
        "Item 2",
        "Item 3",
    ]
);