Skip to content

Commit 1d08350

Browse files
committed
feature #2287 [Icons] Improve icons:lock command verbosity (smnandre)
This PR was merged into the 2.x branch. Discussion ---------- [Icons] Improve `icons:lock` command verbosity | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Issues | #2272 | License | MIT * display "Icon Not Found" (verbose) * display "IconSet Not Found" (very verbose) --- | verbose | very verbose | | - | - | | <img width="891" alt="icon-lock-v" src="https://github.com/user-attachments/assets/42dded28-839b-4fcf-8c17-9147addb7652"> | <img width="889" alt="icon-lock" src="https://github.com/user-attachments/assets/115d2eb7-4c8d-4299-8aac-b72c8a7b6289"> Commits ------- d592cd7 [Icons] Improve `icons:lock` command verbosity
2 parents 923878b + d592cd7 commit 1d08350

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Icons/src/Command/LockIconsCommand.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7272

7373
[$prefix, $name] = $parts;
7474

75+
if (!$this->iconify->hasIconSet($prefix)) {
76+
// not an icon set? example: "og:twitter"
77+
if ($io->isVeryVerbose()) {
78+
$io->writeln(\sprintf(' <fg=bright-yellow;options=bold>✗</> IconSet Not Found: <fg=bright-white;bg=black>%s:%s</>.', $prefix, $name));
79+
}
80+
continue;
81+
}
82+
7583
try {
7684
$svg = $this->iconify->fetchSvg($prefix, $name);
7785
} catch (IconNotFoundException) {
7886
// icon not found on iconify
87+
if ($io->isVerbose()) {
88+
$io->writeln(\sprintf(' <fg=bright-red;options=bold>✗</> Icon Not Found: <fg=bright-white;bg=black>%s:%s</>.', $prefix, $name));
89+
}
7990
continue;
8091
}
8192

@@ -84,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8495
$license = $this->iconify->metadataFor($prefix)['license'];
8596
++$count;
8697

87-
$io->text(\sprintf(
98+
$io->writeln(\sprintf(
8899
" <fg=bright-green;options=bold>✓</> Imported <fg=bright-white;bg=black>%s:</><fg=bright-magenta;bg=black;options>%s</> (License: <href=%s>%s</>). Render with: <comment>{{ ux_icon('%s') }}</comment>",
89100
$prefix,
90101
$name,

src/Icons/src/Iconify.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ public function fetchSvg(string $prefix, string $name): string
104104
return $svg;
105105
}
106106

107+
public function hasIconSet(string $prefix): bool
108+
{
109+
return isset($this->sets()[$prefix]);
110+
}
111+
107112
public function getIconSets(): array
108113
{
109114
return $this->sets()->getArrayCopy();

0 commit comments

Comments
 (0)