-
-
Notifications
You must be signed in to change notification settings - Fork 0
Output streams
Command output is written to StreamName::OUT by default. To write to another stream, pass a StreamName enum value to the output helper.
use GT\Cli\StreamName;
$this->writeLine("Saved successfully");
$this->writeLine("Could not save file", StreamName::ERROR);The available stream names are:
StreamName::INStreamName::OUTStreamName::ERROR
Using StreamName prevents accidental writes to unknown stream names. Passing a raw string such as "error" is not supported.
writeLine() appends a line ending after the message. write() writes the message exactly as provided.
$this->write("Downloading...");
$this->writeLine("done");Both helpers accept a StreamName argument:
$this->write("Warning: ", StreamName::ERROR);
$this->writeLine("configuration file missing", StreamName::ERROR);The output() helper writes a coloured line and also accepts a stream name as its fourth argument:
$this->output(
"Could not connect",
Palette::RED,
null,
StreamName::ERROR
);Progress bars and cursor helpers also use StreamName when you need to target a stream other than standard output.
Next, read coloured output for terminal styling, or progress bars for in-place updates.
PHP.GT/Cli is a separately maintained component of PHP.GT/WebEngine.