8000 [Console] Only show namespaces with commands · symfony/symfony@7214bdd · GitHub
[go: up one dir, main page]

Skip to content

Commit 7214bdd

Browse files
committed
[Console] Only show namespaces with commands
1 parent 6f2ea67 commit 7214bdd

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,25 @@ protected function describeApplication(Application $application, array $options
201201
$commands = $description->getCommands();
202202

203203
foreach ($description->getNamespaces() as $namespace) {
204+
$namespace['commands'] = array_filter($namespace['commands'], function ($name) use ($commands) {
205+
return isset($commands[$name]);
206+
});
207+
208+
if (!$namespace['commands']) {
209+
continue;
210+
}
211+
204212
if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
205213
$this->writeText("\n");
206214
$this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
207215
}
208216

209217
foreach ($namespace['commands'] as $name) {
210-
if (isset($commands[$name])) {
211-
$this->writeText("\n");
212-
$spacingWidth = $width - strlen($name);
213-
$command = $commands[$name];
214-
$commandAliases = $this->getCommandAliasesText($command);
215-
$this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
216-
}
218+
$this->writeText("\n");
219+
$spacingWidth = $width - strlen($name);
220+
$command = $commands[$name];
221+
$commandAliases = $this->getCommandAliasesText($command);
222+
$this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options);
217223
}
218224
}
219225

@@ -234,9 +240,9 @@ private function writeText($content, array $options = array())
234240

235241
/**
236242
* Formats command aliases to show them in the command description.
237-
*
243+
*
238244
* @param Command $command
239-
*
245+
*
240246
* @return string
241247
*/
242248
private function getCommandAliasesText($command)

0 commit comments

Comments
 (0)
0