minor #19275 [Console][FrameworkBundle] Revised console header formatting (ro0NL)

This PR was squashed before being merged into the 3.2-dev branch (closes #19275).

Discussion
----------

[Console][FrameworkBundle] Revised console header formatting

| Q             | A
| ------------- | ---
| Branch?       | "master"
| Bug fix?      | no
| New feature?  | yes (ui change)
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | not yet
| Fixed tickets | #19095
| License       | MIT
| Doc PR        | reference to the documentation PR, if any

Before/After
![image](https://cloud.githubusercontent.com/assets/1047696/16983804/e36c95e0-4e76-11e6-854d-dfa22c634b39.png)

Commits
-------

fcddb3a [Console][FrameworkBundle] Revised console header formatting
This commit is contained in:
Fabien Potencier 2016-07-29 05:54:40 -04:00
commit ad85c79d3d
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