Input / Output
The Centum\Console\Terminal
provides a simple interface for interacting with the terminal, handling both input and output. By default, it reads from STDIN
and writes to STDOUT
and STDERR
.
Constructor
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
.
Example: Creating a Terminal
use Centum\Console\Terminal;
use Centum\Interfaces\Console\Terminal\ArgumentsInterface;
/** @var ArgumentsInterface $arguments */
$terminal = new Terminal($arguments);
Input
Accessing Arguments
Retrieve CLI arguments passed to your command:
$arguments = $terminal->getArguments();
You can then access individual arguments or options as needed.
Output
Writing to STDOUT
$terminal->write("hello"); // Writes without newline
$terminal->writeLine("hello"); // Writes with newline
Writing to STDERR
$terminal->writeError("error"); // Writes error message without newline
$terminal->writeErrorLine("error"); // Writes error message with newline