GenerateCharsetCommand.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. declare(strict_types=1);
  3. namespace Shlinkio\Shlink\CLI\Command\Config;
  4. use Shlinkio\Shlink\CLI\Util\ExitCodes;
  5. use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
  6. use Symfony\Component\Console\Command\Command;
  7. use Symfony\Component\Console\Input\InputInterface;
  8. use Symfony\Component\Console\Output\OutputInterface;
  9. use Symfony\Component\Console\Style\SymfonyStyle;
  10. use function sprintf;
  11. use function str_shuffle;
  12. /** @deprecated */
  13. class GenerateCharsetCommand extends Command
  14. {
  15. public const NAME = 'config:generate-charset';
  16. protected function configure(): void
  17. {
  18. $this
  19. ->setName(self::NAME)
  20. ->setDescription(sprintf(
  21. '[DEPRECATED] Generates a character set sample just by shuffling the default one, "%s". '
  22. . 'Then it can be set in the SHORTCODE_CHARS environment variable',
  23. UrlShortenerOptions::DEFAULT_CHARS
  24. ))
  25. ->setHelp('<fg=red;options=bold>This command is deprecated. Better leave shlink generate the charset.</>');
  26. }
  27. protected function execute(InputInterface $input, OutputInterface $output): ?int
  28. {
  29. $charSet = str_shuffle(UrlShortenerOptions::DEFAULT_CHARS);
  30. (new SymfonyStyle($input, $output))->success(sprintf('Character set: "%s"', $charSet));
  31. return ExitCodes::EXIT_SUCCESS;
  32. }
  33. }