Skip to content

Commit

Permalink
feature #2287 [Icons] Improve icons:lock command verbosity (smnandre)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kbond committed Oct 21, 2024
2 parents 923878b + d592cd7 commit 1d08350
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Icons/src/Command/LockIconsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int

[$prefix, $name] = $parts;

if (!$this->iconify->hasIconSet($prefix)) {
// not an icon set? example: "og:twitter"
if ($io->isVeryVerbose()) {
$io->writeln(\sprintf(' <fg=bright-yellow;options=bold>✗</> IconSet Not Found: <fg=bright-white;bg=black>%s:%s</>.', $prefix, $name));
}
continue;
}

try {
$svg = $this->iconify->fetchSvg($prefix, $name);
} catch (IconNotFoundException) {
// icon not found on iconify
if ($io->isVerbose()) {
$io->writeln(\sprintf(' <fg=bright-red;options=bold>✗</> Icon Not Found: <fg=bright-white;bg=black>%s:%s</>.', $prefix, $name));
}
continue;
}

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

$io->text(\sprintf(
$io->writeln(\sprintf(
" <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>",
$prefix,
$name,
Expand Down
5 changes: 5 additions & 0 deletions src/Icons/src/Iconify.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public function fetchSvg(string $prefix, string $name): string
return $svg;
}

public function hasIconSet(string $prefix): bool
{
return isset($this->sets()[$prefix]);
}

public function getIconSets(): array
{
return $this->sets()->getArrayCopy();
Expand Down

0 comments on commit 1d08350

Please sign in to comment.