Skip to content

Commit

Permalink
chore(console): styling improvements (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt authored Dec 6, 2024
1 parent 420e5d8 commit 839cf60
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Tempest/Console/src/GenericConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function warning(string $line, ?string $symbol = null): self

public function success(string $line, ?string $symbol = null): self
{
$symbol ??= '✔︎';
$symbol ??= '';

$this->writeln("<style=\"bg-dark-green fg-white\"> {$symbol} </style> <style=\"fg-green\">{$line}</style>");

Expand Down
3 changes: 1 addition & 2 deletions src/Tempest/Console/src/Middleware/OverviewMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ private function renderOverview(bool $showHidden = false): void
->toString();

$this->console
->writeln()
->writeln()
->writeln($title);

Expand All @@ -91,7 +90,7 @@ private function renderOverview(bool $showHidden = false): void
$this->console
->unless(
condition: $this->discoveryCache->isValid(),
callback: fn (Console $console) => $console->writeln(PHP_EOL . '<error>Discovery cache invalid. Run discovery:generate to enable discovery caching.</error>'),
callback: fn (Console $console) => $console->writeln()->error('Discovery cache invalid. Run discovery:generate to enable discovery caching.'),
);
}
}
23 changes: 23 additions & 0 deletions tests/Fixtures/Console/StylingCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Tests\Tempest\Fixtures\Console;

use Tempest\Console\ConsoleCommand;
use Tempest\Console\HasConsole;

final readonly class StylingCommand
{
use HasConsole;

#[ConsoleCommand(name: 'test:style')]
public function __invoke(): void
{
$this
->info('info')
->success('success')
->warning('warning')
->error('error');
}
}

0 comments on commit 839cf60

Please sign in to comment.