public function preRun(): void {
    if ($output = $this->getOutput()) {
      $max = 0;
      $iterator = $this->getIterator();

      if ($iterator instanceof \SplFileObject) {
        $max = $iterator->getSize();
      }
      elseif ($iterator instanceof \Countable) {
        $max = count($iterator);
      }

      $this->progress = new ProgressBar($output, $max);
      if ($output->isDecorated()) {
        // If output is not decorated, the redraw frequency would automatically
        // be set to $max/10 by default.
        $this->progress->setRedrawFrequency($max / 100);
      }
      $this->progress->start();
    }
  }