From 017551721d14d082db10532c9676328c0cb48609 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sun, 5 Nov 2023 07:46:21 -0500 Subject: [PATCH] Add an attribute for formatter options (#5805) * Add an attribute for formatter options * Revert changed to QueueCommands --- src/Attributes/Format.php | 35 ++++++++++++++++++++++++++++ src/Attributes/Obsolete.php | 2 +- src/Commands/core/CoreCommands.php | 3 +-- src/Commands/core/StatusCommands.php | 3 +-- 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/Attributes/Format.php diff --git a/src/Attributes/Format.php b/src/Attributes/Format.php new file mode 100644 index 0000000000..0c121d59c1 --- /dev/null +++ b/src/Attributes/Format.php @@ -0,0 +1,35 @@ +newInstance(); + $commandInfo->addAnnotation(FormatterOptions::LIST_DELIMITER, $instance->listDelimiter); + $commandInfo->addAnnotation(FormatterOptions::TABLE_STYLE, $instance->tableStyle); + } +} diff --git a/src/Attributes/Obsolete.php b/src/Attributes/Obsolete.php index f773c744c7..c8b1507a30 100644 --- a/src/Attributes/Obsolete.php +++ b/src/Attributes/Obsolete.php @@ -9,7 +9,7 @@ /** * Mark commands as obsolete. These commands are omitted from help list and when - * user tries to run one the commmand's description is shown. Example usage at https://github.com/drush-ops/drush/blob/12.x/src/Commands/LegacyCommands.php + * user tries to run one, the command's description is shown. Example usage at https://github.com/drush-ops/drush/blob/12.x/src/Commands/LegacyCommands.php */ #[Attribute(Attribute::TARGET_METHOD)] class Obsolete extends NoArgumentsBase diff --git a/src/Commands/core/CoreCommands.php b/src/Commands/core/CoreCommands.php index 8fe92c9e26..a3977f8ac0 100644 --- a/src/Commands/core/CoreCommands.php +++ b/src/Commands/core/CoreCommands.php @@ -69,8 +69,7 @@ public function globalOptions($options = ['format' => 'table']): RowsOfFields * Show Drush version. */ #[CLI\Command(name: self::VERSION)] - #[CLI\HookSelector(name: 'table-style', value: 'compact')] - #[CLI\HookSelector(name: 'list-delimiter', value: ':')] + #[CLI\Format(listDelimiter: ':', tableStyle: 'compact')] #[CLI\FieldLabels(labels: ['drush-version' => 'Drush version'])] public function version($options = ['format' => 'table']): PropertyList { diff --git a/src/Commands/core/StatusCommands.php b/src/Commands/core/StatusCommands.php index 70b409bdbb..c89d7b31c8 100644 --- a/src/Commands/core/StatusCommands.php +++ b/src/Commands/core/StatusCommands.php @@ -36,8 +36,7 @@ final class StatusCommands extends DrushCommands implements SiteAliasManagerAwar #[CLI\Option(name: 'project', description: 'A comma delimited list of projects. Their paths will be added to path-aliases section.')] #[CLI\Usage(name: 'drush core-status --field=files', description: 'Emit just one field, not all the default fields.')] #[CLI\Usage(name: 'drush core-status --fields=*', description: 'Emit all fields, not just the default ones.')] - #[CLI\HookSelector(name: 'table-style', value: 'compact')] - #[CLI\HookSelector(name: 'list-delimiter', value: ':')] + #[CLI\Format(listDelimiter: ':', tableStyle: 'compact')] #[CLI\FieldLabels(labels: [ 'drupal-version' => 'Drupal version', 'uri' => 'Site URI',