Skip to content

Commit

Permalink
Allow commands to return an exit code (#3078)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jorissteyn authored and jmolivas committed Jan 7, 2017
1 parent 7fa61ca commit 2379eea
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 2379eea

Please sign in to comment.