From 2379eeae56b477eca915d2b9d485911dbab814e3 Mon Sep 17 00:00:00 2001 From: Joris Steyn Date: Sat, 7 Jan 2017 05:48:47 +0100 Subject: [PATCH] Allow commands to return an exit code (#3078) It is important for any program to exit with a non-zero exit code if it encountered an error. In Symfony console commands it's common to return with an exit code in the execute() method of a command. Drupal Console disregards this exit code in Application::doRun(), making it harder to use Drupal Console in a scriptable way. --- src/Application.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Application.php b/src/Application.php index a0bd51b5f..38aa22241 100644 --- a/src/Application.php +++ b/src/Application.php @@ -53,12 +53,16 @@ public function doRun(InputInterface $input, OutputInterface $output) if ($clear === true || $clear === 'true') { $output->write(sprintf("\033\143")); } - parent::doRun($input, $output); + + $exitCode = parent::doRun($input, $output); + if ($this->getCommandName($input) == 'list' && $this->container->hasParameter('console.warning')) { $io->warning( $this->trans($this->container->getParameter('console.warning')) ); } + + return $exitCode; } private function registerGenerators()