forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrushCommandInfoAlterer.php
29 lines (26 loc) · 1.31 KB
/
DrushCommandInfoAlterer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace Drush\Command;
use Consolidation\AnnotatedCommand\CommandInfoAltererInterface;
use Consolidation\AnnotatedCommand\Parser\CommandInfo;
class DrushCommandInfoAlterer implements CommandInfoAltererInterface
{
public function alterCommandInfo(CommandInfo $commandInfo, $commandFileInstance): void
{
// If a command has a @filter-default-field annotation, that
// implies that it also has an implicit @filter-output annotation.
if ($commandInfo->hasAnnotation('filter-default-field') && !$commandInfo->hasAnnotation('filter-output')) {
$commandInfo->addAnnotation('filter-output', true);
}
// Automatically add the help topic for output formatters to
// any command that has any annotations related to output filters
if ($commandInfo->hasAnnotation('filter-output') || $commandInfo->hasAnnotation('field-labels')) {
if ($commandInfo->hasAnnotation('topics')) {
// Topic value may have multiple values separated by a comma.
$values = $commandInfo->getAnnotationList('topics');
$commandInfo->removeAnnotation('topics');
$commandInfo->addAnnotation('topics', $values);
}
$commandInfo->addAnnotation('topics', 'docs:output-formats-filters');
}
}
}