Skip to content

Commit 71e9334

Browse files
authored
Merge pull request #1288 from hydephp/list-command-logo-should-respect-the-no-ansi-setting
Use "HydePHP" as the application logo when running without ANSI formatting
2 parents fd416d0 + 3594354 commit 71e9334

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

RELEASE_NOTES.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This serves two purposes:
2323

2424
### Fixed
2525
- Fixed "ReadingTime calculation should never be under one minute" [#1286](https://github.com/hydephp/develop/issues/1286) in [#1285](https://github.com/hydephp/develop/pull/1285)
26+
- Fixed "The HydeCLI list command logo should respect the --no-ansi setting" [#1127](https://github.com/hydephp/develop/issues/1127) in [#1288](https://github.com/hydephp/develop/pull/1288)
2627

2728
### Security
2829
- in case of vulnerabilities.

packages/framework/src/Console/ConsoleServiceProvider.php

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public function register(): void
4545

4646
protected static function logo(): string
4747
{
48+
// Check if no-ansi flag is set
49+
if (isset($_SERVER['argv']) && in_array('--no-ansi', $_SERVER['argv'], true)) {
50+
return 'HydePHP';
51+
}
52+
4853
return <<<ASCII
4954
5055
\033[34m __ __ __ \033[33m ___ __ _____
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Hyde\Framework\Testing\Unit;
6+
7+
use Hyde\Console\ConsoleServiceProvider;
8+
use Hyde\Testing\UnitTestCase;
9+
10+
/**
11+
* @covers \Hyde\Console\ConsoleServiceProvider
12+
*/
13+
class ConsoleServiceProviderUnitTest extends UnitTestCase
14+
{
15+
public function testProviderRegistersLogo()
16+
{
17+
$this->assertSame(<<<ASCII
18+
19+
\033[34m __ __ __ \033[33m ___ __ _____
20+
\033[34m / // /_ _____/ /__ \033[33m/ _ \/ // / _ \
21+
\033[34m / _ / // / _ / -_)\033[33m ___/ _ / ___/
22+
\033[34m /_//_/\_, /\_,_/\__/\033[33m_/ /_//_/_/
23+
\033[34m /___/
24+
25+
\033[0m
26+
ASCII, ConsoleServiceProviderTestClass::logo());
27+
}
28+
29+
public function testProviderRegistersNoAnsiLogo()
30+
{
31+
$serverBackup = $_SERVER;
32+
33+
$_SERVER['argv'] = ['--no-ansi'];
34+
35+
$this->assertSame('HydePHP', ConsoleServiceProviderTestClass::logo());
36+
37+
$_SERVER = $serverBackup;
38+
}
39+
}
40+
41+
class ConsoleServiceProviderTestClass extends ConsoleServiceProvider
42+
{
43+
public static function logo(): string
44+
{
45+
return parent::logo();
46+
}
47+
}

0 commit comments

Comments
 (0)