Skip to content

Commit

Permalink
fix: clear line
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Sep 29, 2023
1 parent 7831ac4 commit c8c0f77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions elasticms-cli/src/Client/Audit/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,19 @@ public function progress(OutputInterface $output): void
$estimateSeconds = \round($rate * ($total - $treated));
$estimateDatetime = new \DateTimeImmutable(\sprintf('+%s seconds', $estimateSeconds));
$dateIntervalFormat = $estimateSeconds > (24 * 60 * 60) ? '%a days %h:%I:%S' : '%h:%I:%S';
$output->write(\sprintf('%d urls audited, %d urls pending, %d urls found, rate %01.2f url/min, EAC in %s ', $treated, $total - $treated, $total, 60.0 / $rate, $estimateDatetime->diff(new \DateTimeImmutable())->format($dateIntervalFormat)));
$output->write(\sprintf('%d urls audited, %d urls pending, %d urls found, rate %01.2f url/min, EAC in %s', $treated, $total - $treated, $total, 60.0 / $rate, $estimateDatetime->diff(new \DateTimeImmutable())->format($dateIntervalFormat)));
}

public function progressFinish(OutputInterface $output, int $counter): void
{
$this->rewindOutput($output);
$output->writeln(\sprintf('%d/%d urls have been audited ', $counter, \count($this->urls)));
$output->writeln(\sprintf('%d/%d urls have been audited', $counter, \count($this->urls)));
}

protected function rewindOutput(OutputInterface $output): void
{
$output->write(\sprintf("\x1b[%dG", 1));
$output->write("\x1b[2K");
}

public function resume(): void
Expand Down

0 comments on commit c8c0f77

Please sign in to comment.