Skip to content

Commit

Permalink
[list] Relocate command alias. (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas committed Jan 22, 2017
1 parent 22db58d commit 801ca7a
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/Descriptor/TextDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,41 @@ protected function describeApplication(Application $application, array $options
$this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
$this->writeText("\n");
$this->writeText("\n");
$width = $this->getColumnWidth($description->getCommands());
$width = $this->getColumnWidth($description->getCommands()) + 4;
if ($describedNamespace) {
$this->writeText(sprintf($application->trans('commands.list.messages.comment'), $describedNamespace), $options);
} else {
}
else {
$this->writeText($application->trans('commands.list.messages.available-commands'), $options);
}
// add commands by namespace
foreach ($description->getNamespaces() as $namespace) {
if (ApplicationDescription::GLOBAL_NAMESPACE == $namespace['id']){
continue;
}
if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
$this->writeText("\n");
$this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
}
foreach ($namespace['commands'] as $name) {
$this->writeText("\n");
$spacingWidth = $width - strlen($name);
$this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
$alias = '';
if ($description->getCommand($name)->getAliases()){
$alias = sprintf(
'(%s)',
implode(',', $description->getCommand($name)->getAliases())
);
}
$spacingWidth = $width - strlen($name.$alias);
$this->writeText(
sprintf(' <info>%s</info> <comment>%s</comment> %s%s',
$name,
$alias,
str_repeat(' ', $spacingWidth),
$description->getCommand($name)->getDescription()
),
$options
);
}
}
$this->writeText("\n");
Expand Down

0 comments on commit 801ca7a

Please sign in to comment.