Skip to content

Commit

Permalink
[console] Validate invalid command. (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Nov 5, 2016
1 parent b2bdf84 commit 7a51b6c
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,36 @@ public function trans($key)

public function doRun(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
if ($commandName = $this->getCommandName($input)) {
$this->commandName = $commandName;
}
$this->registerEvents();
$this->registerCommandsFromAutoWireConfiguration();

/**
* @var ConfigurationManager $configurationManager
*/
$configurationManager = $this->container
->get('console.configuration_manager');

if (!$this->has($commandName)) {
$io->error(
sprintf(
$this->trans('application.errors.invalid-command'),
$this->commandName
)
);

return 1;
}

$code = parent::doRun(
$input,
$output
);

/**
* @var ConfigurationManager $configurationManager
*/
$configurationManager = $this->container->get('console.configuration_manager');
if ($this->commandName != 'init' && $configurationManager->getMissingConfigurationFiles()) {
$io = new DrupalStyle($input, $output);
$io->warning($this->trans('application.site.errors.missing-config-file'));
$io->listing($configurationManager->getMissingConfigurationFiles());
$io->commentBlock(
Expand Down

0 comments on commit 7a51b6c

Please sign in to comment.