diff --git a/src/Console/AbstractCommand.php b/src/Console/AbstractCommand.php index 3d01d5ecc..821d4f8a8 100644 --- a/src/Console/AbstractCommand.php +++ b/src/Console/AbstractCommand.php @@ -13,6 +13,7 @@ namespace Flarum\Console; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; abstract class AbstractCommand extends Command @@ -55,12 +56,28 @@ abstract class AbstractCommand extends Command } /** - * Send an info string to the user. + * Send an info message to the user. * - * @param string $string + * @param string $message */ - protected function info($string) + protected function info($message) { - $this->output->writeln("$string"); + $this->output->writeln("$message"); + } + + /** + * Send an error or warning message to the user. + * + * If possible, this will send the message via STDERR. + * + * @param string $message + */ + protected function error($message) + { + if ($this->output instanceof ConsoleOutputInterface) { + $this->output->getErrorOutput()->writeln("$message"); + } else { + $this->output->writeln("$message"); + } } } diff --git a/src/Foundation/Console/InfoCommand.php b/src/Foundation/Console/InfoCommand.php index fe81eb624..6f1e9cabd 100644 --- a/src/Foundation/Console/InfoCommand.php +++ b/src/Foundation/Console/InfoCommand.php @@ -73,6 +73,12 @@ class InfoCommand extends AbstractCommand $this->info('Base URL: '.$this->config['url']); $this->info('Installation path: '.getcwd()); $this->info('Debug mode '.($this->config['debug'] ? 'ON' : 'off')); + + if ($this->config['debug']) { + $this->error( + "Don't forget to turn off debug mode! It should never be turned on in a production system." + ); + } } /**