8000 [Console][FrameworkBundle] Revised console header formatting by ro0NL · Pull Request #19275 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console][FrameworkBundle] Revised console header formatting #19275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Console/Application.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<info>Console Tool</info>
Console Tool

<comment>Usage:</comment>
command [options] [arguments]
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<info>Console Tool</info>
Console Tool
0