Skip to content

Conversation

kodie
Copy link
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
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
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
Owner

adhocore commented Dec 1, 2024

cool, thanks 👍

@adhocore adhocore merged commit cd0152f into adhocore:main Dec 1, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants