Skip to content

Commit

Permalink
[console] Show version and execution path. (#3358)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Jun 27, 2017
1 parent 2c64b3c commit 1501cf9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
26 changes: 22 additions & 4 deletions bin/drupal.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php

use Drupal\Console\Core\Utils\DrupalFinder;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Input\ArrayInput;
use Drupal\Console\Core\Utils\ConfigurationManager;
use Drupal\Console\Core\Utils\ArgvInputReader;
use Drupal\Console\Core\Utils\DrupalFinder;
use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Bootstrap\Drupal;
use Drupal\Console\Application;
use Drupal\Console\Core\Utils\ConfigurationManager;

set_time_limit(0);

Expand Down Expand Up @@ -33,9 +36,13 @@
exit(1);
}

$output = new ConsoleOutput();
$input = new ArrayInput([]);
$io = new DrupalStyle($input, $output);

$drupalFinder = new DrupalFinder();
if (!$drupalFinder->locateRoot(getcwd())) {
echo ' DrupalConsole must be executed within a Drupal Site.'.PHP_EOL;
$io->error('DrupalConsole must be executed within a Drupal Site.');

exit(1);
}
Expand All @@ -47,16 +54,27 @@
->loadConfigurationFromDirectory($drupalFinder->getComposerRoot());

$argvInputReader = new ArgvInputReader();
$debug = $argvInputReader->get('debug', false);
if ($configuration && $options = $configuration->get('application.options') ?: []) {
$argvInputReader->setOptionsFromConfiguration($options);
}
$argvInputReader->setOptionsAsArgv();

if ($debug){
$io->writeln(
sprintf(
'<info>%s</info> version <comment>%s</comment>',
Application::NAME,
Application::VERSION
)
);
}

$drupal = new Drupal($autoload, $drupalFinder);
$container = $drupal->boot();

if (!$container) {
echo ' Something was wrong. Drupal can not be bootstrap.';
$io->error('Something was wrong. Drupal can not be bootstrap.');

exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getLongVersion()
$output .= sprintf('<info>%s</info>', $this->getName());
}
} else {
$output .= '<info>Console Tool</info>';
$output .= '<info>Drupal Console</info>';
}

return $output;
Expand Down
1 change: 0 additions & 1 deletion src/Bootstrap/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Core\Utils\ArgvInputReader;
use Drupal\Console\Core\Bootstrap\DrupalConsoleCore;
use Drupal\Console\Utils\ExtendExtensionManager;
use Drupal\Console\Core\Utils\DrupalFinder;

class Drupal
Expand Down

0 comments on commit 1501cf9

Please sign in to comment.