55use Illuminate \Filesystem \Filesystem ;
66use SplFileInfo ;
77use Symfony \Component \Console \Command \Command ;
8+ use Symfony \Component \Console \Helper \ProgressBar ;
89use Symfony \Component \Console \Input \InputInterface ;
910use 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