public __construct ( Symfony\Component\Console\Output\OutputInterface $output, integer $max ) | ||
$output | Symfony\Component\Console\Output\OutputInterface | An OutputInterface instance |
$max | integer | Maximum steps (0 if unknown) |
/** * Configure progress panel * * @param OutputInterface $output * @param int $max */ public function __construct(OutputInterface $output, $max = 0) { static::setPlaceholderFormatterDefinition('current', function (ProgressBar $bar) { return $bar->getProgress(); }); parent::__construct($output, $max); if ($max === 0) { $this->setFormat('%data% %current% [%bar%] %elapsed:10s% / %memory:-10s% %itemsPerSecond:-10s% %message%'); } else { $this->setFormat('%data% %current%/%max% [%bar%] %percent:3s%% %elapsed:10s% / %estimated:-10s% %memory:-10s% %itemsPerSecond:-10s% %message%'); } $this->setMessage('', 'data'); $this->setMessage(''); static::setPlaceholderFormatterDefinition('itemsPerSecond', function (ProgressBar $bar) { $seconds = time() - $bar->getStartTime(); $seconds = empty($seconds) ? 1 : $seconds; return round($bar->getProgress() / $seconds) . ' i/s'; }); }
public function __construct(OutputInterface $output, $max) { parent::__construct($output, $max); $this->setFormat('%percent%% (%current% / %max%) %message%'); $this->setMessage('<comment>Waiting...</comment>', 'message', false); }