[Console][FrameworkBundle] Revised console header formatting

This commit is contained in:
Roland Franssen 2016-07-01 08:05:06 +00:00 committed by Fabien Potencier
parent ec3a4ede27
commit fcddb3a9c9
6 changed files with 18 additions and 10 deletions

View File

@ -39,10 +39,10 @@ class Application extends BaseApplication
{
$this->kernel = $kernel;
parent::__construct('Symfony', Kernel::VERSION.' - '.$kernel->getName().'/'.$kernel->getEnvironment().($kernel->isDebug() ? '/debug' : ''));
parent::__construct('Symfony', Kernel::VERSION);
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The environment name', $kernel->getEnvironment()));
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode'));
}
/**
@ -100,6 +100,14 @@ class Application extends BaseApplication
return parent::all($namespace);
}
/**
* {@inheritdoc}
*/
public function getLongVersion()
{
return parent::getLongVersion().sprintf(' (kernel: <comment>%s</>, env: <comment>%s</>, debug: <comment>%s</>)', $this->kernel->getName(), $this->kernel->getEnvironment(), $this->kernel->isDebug() ? 'true' : 'false');
}
protected function registerCommands()
{
if ($this->commandsRegistered) {

View File

@ -336,13 +336,13 @@ class Application
{
if ('UNKNOWN' !== $this->getName()) {
if ('UNKNOWN' !== $this->getVersion()) {
return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion());
}
return sprintf('<info>%s</info>', $this->getName());
return $this->getName();
}
return '<info>Console Tool</info>';
return 'Console Tool';
}
/**

View File

@ -91,7 +91,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testGetLongVersion()
{
$application = new Application('foo', 'bar');
$this->assertEquals('<info>foo</info> version <comment>bar</comment>', $application->getLongVersion(), '->getLongVersion() returns the long version of the application');
$this->assertEquals('foo <info>bar</info>', $application->getLongVersion(), '->getLongVersion() returns the long version of the application');
}
public function testHelp()

View File

@ -1,4 +1,4 @@
<info>Console Tool</info>
Console Tool
<comment>Usage:</comment>
command [options] [arguments]

View File

@ -1,4 +1,4 @@
<info>My Symfony application</info> version <comment>v1.0</comment>
My Symfony application <info>v1.0</info>
<comment>Usage:</comment>
command [options] [arguments]

View File

@ -1 +1 @@
<info>Console Tool</info>
Console Tool