8000 [Console] MarkdownDescriptor: Don't use getLongVersion by ogizanagi · Pull Request #20903 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] MarkdownDescriptor: Don't use getLongVersion #20903

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 1 commit 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
17 changes: 16 additions & 1 deletion src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Helper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -122,8 +123,9 @@ protected function describeApplication(Application $application, array $options
{
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
$description = new ApplicationDescription($application, $describedNamespace);
$title = $this->getApplicationTitle($application);

$this->write($application->getLongVersion()."\n".str_repeat('=', strlen($application->getLongVersion())));
$this->write($title."\n".str_repeat('=', Helper::strlen($title)));

foreach ($description->getNamespaces() as $namespace) {
if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
Expand All @@ -142,4 +144,17 @@ protected function describeApplication(Application $application, array $options
$this->write($this->describeCommand($command));
}
}

private function getApplicationTitle(Application $application)
{
if ('UNKNOWN' !== $application->getName()) {
if ('UNKNOWN' !== $application->getVersion()) {
return sprintf('%s %s', $application->getName(), $application->getVersion());
}

return $application->getName();
}

return 'Console Tool';
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Tests/Fixtures/application_2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
My Symfony application <info>v1.0</info>
========================================
My Symfony application v1.0
===========================

* `alias1`
* `alias2`
Expand Down
0