Cake\Console\ConsoleIo::overwrite PHP Method

overwrite() public method

Useful for building progress bars, or when you want to replace text already output to the screen with new text. **Warning** You cannot overwrite text that contains newlines.
public overwrite ( array | string $message, integer $newlines = 1, integer | null $size = null ) : void
$message array | string The message to output.
$newlines integer Number of newlines to append.
$size integer | null The number of bytes to overwrite. Defaults to the length of the last message output.
return void
    public function overwrite($message, $newlines = 1, $size = null)
    {
        $size = $size ?: $this->_lastWritten;
        // Output backspaces.
        $this->out(str_repeat("", $size), 0);
        $newBytes = $this->out($message, 0);
        // Fill any remaining bytes with spaces.
        $fill = $size - $newBytes;
        if ($fill > 0) {
            $this->out(str_repeat(' ', $fill), 0);
        }
        if ($newlines) {
            $this->out($this->nl($newlines), 0);
        }
    }