Skip to content

Commit be293bc

Browse files
committed
WIP
1 parent 3c1cd13 commit be293bc

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

src/BuildCommand.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Filesystem\Filesystem;
66
use SplFileInfo;
77
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Helper\ProgressBar;
89
use Symfony\Component\Console\Input\InputInterface;
910
use Symfony\Component\Console\Output\OutputInterface;
1011

@@ -59,14 +60,15 @@ public function execute(InputInterface $input, OutputInterface $output): int
5960
->withAuthor($config['author'])
6061
->setFooter('<div id="footer" style="text-align: center">{PAGENO}</div>');
6162

62-
$output->writeln('<fg=yellow>==></> Building PDF page by page ...');
63-
6463
$files = collect($this->disk->files($currentPath.'/content'))
6564
->filter(fn (SplFileInfo $file) => $file->getExtension() === 'md')
6665
->values();
6766

6867
$processor = new MarkdownProcessor();
6968

69+
$progressBar = new ProgressBar($output, $files->count());
70+
$progressBar->start();
71+
7072
foreach ($files as $index => $file) {
7173

7274
$html = $processor->convert(
@@ -76,20 +78,23 @@ public function execute(InputInterface $input, OutputInterface $output): int
7678

7779
// Добавляем страницу, кроме последней
7880
$pdf->chapter($html, $index < $files->count() - 1);
79-
}
8081

81-
$output->writeln('<fg=yellow>==></> Writing PDF To Disk ...');
82-
$output->writeln('');
82+
$progressBar->advance();
83+
}
8384

84-
$output->writeln('✨✨ '.$pdf->getPageCount().' PDF pages ✨✨');
85+
$progressBar->finish();
8586

8687
$pdfFilePath = sprintf('%s/export/%s.pdf', $currentPath, $config['title']);
8788
$pdf->Output($pdfFilePath);
8889

90+
$output->writeln('');
91+
$output->writeln(
92+
sprintf('<fg=yellow>==></> Writing %s PDF Pages To Disk ...', $pdf->getPageCount())
93+
);
94+
8995
// Создаем кликабельную ссылку для поддерживающих терминалов
90-
$output->writeln('✨✨ '.$pdf->getPageCount().' PDF pages ✨✨');
9196
$output->writeln(sprintf(
92-
'<href=file://%s>📄 Click to open: %s</>',
97+
' <href=file://%s>📄 Click to open: %s</>',
9398
$pdfFilePath,
9499
$pdfFilePath
95100
));

0 commit comments

Comments
 (0)