diff --git a/module/CLI/src/Command/Shortcode/GeneratePreviewCommand.php b/module/CLI/src/Command/Shortcode/GeneratePreviewCommand.php
index fec666bf..6fa0a487 100644
--- a/module/CLI/src/Command/Shortcode/GeneratePreviewCommand.php
+++ b/module/CLI/src/Command/Shortcode/GeneratePreviewCommand.php
@@ -9,6 +9,7 @@ use Shlinkio\Shlink\Core\Service\ShortUrlServiceInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
use Zend\I18n\Translator\TranslatorInterface;
class GeneratePreviewCommand extends Command
@@ -61,22 +62,20 @@ class GeneratePreviewCommand extends Command
}
} while ($page <= $shortUrls->count());
- $output->writeln('' . $this->translator->translate('Finished processing all URLs') . '');
+ (new SymfonyStyle($input, $output))->success($this->translator->translate('Finished processing all URLs'));
}
protected function processUrl($url, OutputInterface $output)
{
try {
- $output->write(sprintf($this->translator->translate('Processing URL %s...'), $url));
+ $output->write(\sprintf($this->translator->translate('Processing URL %s...'), $url));
$this->previewGenerator->generatePreview($url);
$output->writeln($this->translator->translate(' Success!'));
} catch (PreviewGenerationException $e) {
- $messages = [' ' . $this->translator->translate('Error') . ''];
+ $output->writeln(' ' . $this->translator->translate('Error') . '');
if ($output->isVerbose()) {
- $messages[] = '' . $e->__toString() . '';
+ $this->getApplication()->renderException($e, $output);
}
-
- $output->writeln($messages);
}
}
}