Improved GenerateCharsetCommand by using SymfonyStyle

This commit is contained in:
Alejandro Celaya 2017-12-28 09:48:17 +01:00
parent 1993d01110
commit 1b94083188

View file

@ -7,6 +7,7 @@ use Shlinkio\Shlink\Core\Service\UrlShortener;
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 GenerateCharsetCommand extends Command
@ -36,6 +37,8 @@ class GenerateCharsetCommand extends Command
public function execute(InputInterface $input, OutputInterface $output)
{
$charSet = str_shuffle(UrlShortener::DEFAULT_CHARS);
$output->writeln($this->translator->translate('Character set:') . sprintf(' <info>%s</info>', $charSet));
(new SymfonyStyle($input, $output))->success(
\sprintf($this->translator->translate('Character set: "%s"'), $charSet)
);
}
}