Skip to content

Allow disabling colors#118

Merged
adhocore merged 10 commits intoadhocore:mainfrom
kodie:kodie/allow-color-disabling
Dec 1, 2024
Merged

Allow disabling colors#118
adhocore merged 10 commits intoadhocore:mainfrom
kodie:kodie/allow-color-disabling

Conversation

@kodie
Copy link
Copy Markdown
Contributor

@kodie kodie commented Nov 28, 2024

Just a tiny implementation that allows us to disable colors:

$command = new Ahc\Cli\Input\Command('test', 'My Test Command'); $command ->option('-n --no-colors', 'Disables terminal colors') ->parse(['thisfile.php', '--no-colors']); if (!$this->colors) { Ahc\Cli\Output\Color::$enabled = false; }
@adhocore
Copy link
Copy Markdown
Owner

adhocore commented Dec 1, 2024

how does it play with html like color of this pkg? eg <boldRed>text</end><eol> should output just "text\n"

basically there are multiple ways to style/print colors, all those must output no color when disabled or env set

@kodie
Copy link
Copy Markdown
Contributor Author

kodie commented Dec 1, 2024

how does it play with html like color of this pkg? eg <boldRed>text</end><eol> should output just "text\n"

basically there are multiple ways to style/print colors, all those must output no color when disabled or env set

Every different way of styling/printing does so by using the line function as far as I could tell and from my tests that seem to be true. <boldRed>text</end><eol> works as you would expect as does the help screen.

@adhocore
Copy link
Copy Markdown
Owner

adhocore commented Dec 1, 2024

cool, thanks 👍

@adhocore adhocore merged commit cd0152f into adhocore:main Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants