From 85f3bb070d874dab84e35cfe93505a39372a556f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 9 Nov 2021 16:04:21 +0100 Subject: [PATCH] Add abandoned flag in search command output --- src/Composer/Command/SearchCommand.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/SearchCommand.php b/src/Composer/Command/SearchCommand.php index a4e63198b..78ed6cab0 100644 --- a/src/Composer/Command/SearchCommand.php +++ b/src/Composer/Command/SearchCommand.php @@ -93,12 +93,13 @@ EOT $nameLength += 1; foreach ($results as $result) { $description = isset($result['description']) ? $result['description'] : ''; - $remaining = $width - $nameLength - 2; + $warning = !empty($result['abandoned']) ? '! Abandoned ! ' : ''; + $remaining = $width - $nameLength - strlen($warning) - 2; if (strlen($description) > $remaining) { $description = substr($description, 0, $remaining - 3) . '...'; } - $io->write(str_pad($result['name'], $nameLength, ' ') . $description); + $io->write(str_pad($result['name'], $nameLength, ' ') . $warning . $description); } } elseif ($format === 'json') { $io->write(JsonFile::encode($results));