private function setCursorToProgressBar(int $index, BufferedOutputInterface $output)
    {
        if ($this->currentIndex > $index) {
            // Move the cursor up.
            $this->moveCursorUp($this->currentIndex - $index, $output);
        } elseif ($this->currentIndex < $index) {
            // Move the cursor down.
            $this->moveCursorDown($index - $this->currentIndex, $output);
        }
    }