Skip to content

Commit

Permalink
minor #19275 [Console][FrameworkBundle] Revised console header format…
Browse files Browse the repository at this point in the history
…ting (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
  • Loading branch information
fabpot committed Jul 29, 2016
2 parents ec3a4ed + fcddb3a commit ad85c79
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
14 changes: 11 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Console/Application.php
Expand Up @@ -39,10 +39,10 @@ public function __construct(KernelInterface $kernel)
{
$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'));
}

/**
Expand Down Expand Up @@ -100,6 +100,14 @@ public function all($namespace = null)
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) {
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Console/Application.php
Expand Up @@ -336,13 +336,13 @@ public function getLongVersion()
{
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';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Tests/ApplicationTest.php
Expand Up @@ -91,7 +91,7 @@ public function testSetGetVersion()
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()
Expand Down
@@ -1,4 +1,4 @@
<info>Console Tool</info>
Console Tool

<comment>Usage:</comment>
command [options] [arguments]
Expand Down
@@ -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]
Expand Down
@@ -1 +1 @@
<info>Console Tool</info>
Console Tool

0 comments on commit ad85c79

Please sign in to comment.