From c0130c997a971621477f9becbbb40880a619e6b1 Mon Sep 17 00:00:00 2001
From: Alejandro Celaya <alejandro@alejandrocelaya.com>
Date: Sat, 16 Feb 2019 22:53:49 +0100
Subject: [PATCH] Deprecated commands to generate secret and charset

---
 CHANGELOG.md                                             | 2 +-
 README.md                                                | 4 ++--
 module/CLI/src/Command/Config/GenerateCharsetCommand.php | 6 ++++--
 module/CLI/src/Command/Config/GenerateSecretCommand.php  | 6 +++++-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5a83475c..b5f6254b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,7 +52,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this
 
 #### Deprecated
 
-* *Nothing*
+* [#351](https://github.com/shlinkio/shlink/issues/351) Deprecated `config:generate-charset` and `config:generate-secret` CLI commands.
 
 #### Removed
 
diff --git a/README.md b/README.md
index 361dbaa3..de893dab 100644
--- a/README.md
+++ b/README.md
@@ -266,8 +266,8 @@ Available commands:
   api-key:generate            Generates a new valid API key.
   api-key:list                Lists all the available API keys.
  config
-  config:generate-charset     Generates a character set sample just by shuffling the default one, "123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ". Then it can be set in the SHORTCODE_CHARS environment variable
-  config:generate-secret      Generates a random secret string that can be used for JWT token encryption
+  config:generate-charset     [DEPRECATED] Generates a character set sample just by shuffling the default one, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ". Then it can be set in the SHORTCODE_CHARS environment variable
+  config:generate-secret      [DEPRECATED] Generates a random secret string that can be used for JWT token encryption
  short-url
   short-url:delete            [short-code:delete] Deletes a short URL
   short-url:generate          [shortcode:generate|short-code:generate] Generates a short URL for provided long URL and returns it
diff --git a/module/CLI/src/Command/Config/GenerateCharsetCommand.php b/module/CLI/src/Command/Config/GenerateCharsetCommand.php
index 34e23195..c7f174cb 100644
--- a/module/CLI/src/Command/Config/GenerateCharsetCommand.php
+++ b/module/CLI/src/Command/Config/GenerateCharsetCommand.php
@@ -11,6 +11,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
 use function sprintf;
 use function str_shuffle;
 
+/** @deprecated */
 class GenerateCharsetCommand extends Command
 {
     public const NAME = 'config:generate-charset';
@@ -20,10 +21,11 @@ class GenerateCharsetCommand extends Command
         $this
             ->setName(self::NAME)
             ->setDescription(sprintf(
-                'Generates a character set sample just by shuffling the default one, "%s". '
+                '[DEPRECATED] Generates a character set sample just by shuffling the default one, "%s". '
                 . 'Then it can be set in the SHORTCODE_CHARS environment variable',
                 UrlShortenerOptions::DEFAULT_CHARS
-            ));
+            ))
+            ->setHelp('<fg=red;options=bold>This command is deprecated. Better leave shlink generate the charset.</>');
     }
 
     protected function execute(InputInterface $input, OutputInterface $output): void
diff --git a/module/CLI/src/Command/Config/GenerateSecretCommand.php b/module/CLI/src/Command/Config/GenerateSecretCommand.php
index 07b051a1..23d559b5 100644
--- a/module/CLI/src/Command/Config/GenerateSecretCommand.php
+++ b/module/CLI/src/Command/Config/GenerateSecretCommand.php
@@ -10,6 +10,7 @@ use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Style\SymfonyStyle;
 use function sprintf;
 
+/** @deprecated */
 class GenerateSecretCommand extends Command
 {
     use StringUtilsTrait;
@@ -20,7 +21,10 @@ class GenerateSecretCommand extends Command
     {
         $this
             ->setName(self::NAME)
-            ->setDescription('[DEPRECATED] Generates a random secret string that can be used for JWT token encryption');
+            ->setDescription('[DEPRECATED] Generates a random secret string that can be used for JWT token encryption')
+            ->setHelp(
+                '<fg=red;options=bold>This command is deprecated. Better leave shlink generate the secret key.</>'
+            );
     }
 
     protected function execute(InputInterface $input, OutputInterface $output): void