diff --git a/README.md b/README.md index b5270df..a8ec82b 100644 --- a/README.md +++ b/README.md @@ -613,15 +613,15 @@ $writer->table([ // In future we may support styling a column by its name! ``` -#### Two columns detail (Display setting) +#### Justify content (Display setting) -If you want to display certain configurations (from your .env file for example) a bit like Laravel does (via the php artisan `about` command) you can use the `twoColumnDetail` method. +If you want to display certain configurations (from your .env file for example) a bit like Laravel does (via the `php artisan about` command) you can use the `justify` method. ```php -$writer->twoColumnDetail('Environment'); -$writer->twoColumnDetail('PHP Version', PHP_VERSION); -$writer->twoColumnDetail('App Version', '1.0.0'); -$writer->twoColumnDetail('Locale', 'en'); +$writer->justify('Environment'); +$writer->justify('PHP Version', PHP_VERSION); +$writer->justify('App Version', '1.0.0'); +$writer->justify('Locale', 'en'); ``` Gives something like: @@ -636,8 +636,8 @@ Locale .......................................... en You can use the `sep` parameter to define the separator to use. ```php -$writer->twoColumnDetail('Environment', '', ['sep' => '-']); -$writer->twoColumnDetail('PHP Version', PHP_VERSION); +$writer->justify('Environment', '', ['sep' => '-']); +$writer->justify('PHP Version', PHP_VERSION); ``` Gives something like: @@ -650,11 +650,11 @@ PHP Version .................................. 8.1.4 In addition, the text color, the background color and the thickness of the two texts can be defined via the 3rd argument of this method. ```php -$writer->twoColumnDetail('Cache Enable', 'true', [ +$writer->justify('Cache Enable', 'true', [ 'first' => ['fg' => Ahc\Cli\Output\Color::CYAN], // style of the key 'second' => ['fg' => Ahc\Cli\Output\Color::GREEN], // style of the value ]); -$writer->twoColumnDetail('Debug Mode', 'false', [ +$writer->justify('Debug Mode', 'false', [ 'first' => ['fg' => Ahc\Cli\Output\Color::CYAN], // style of the key 'second' => ['fg' => Ahc\Cli\Output\Color::RED], // style of the value ]); diff --git a/src/Output/Writer.php b/src/Output/Writer.php index bf7718c..83346be 100644 --- a/src/Output/Writer.php +++ b/src/Output/Writer.php @@ -313,7 +313,7 @@ public function table(array $rows, array $styles = []): self * * @return self */ - public function twoColumnDetail(string $first, ?string $second = null, array $options = []): self + public function justify(string $first, ?string $second = null, array $options = []): self { $options = [ 'first' => ($options['first'] ?? []) + ['bg' => null, 'fg' => Color::WHITE, 'bold' => 0], diff --git a/tests/Output/WriterTest.php b/tests/Output/WriterTest.php index 1973cfc..f2c9950 100644 --- a/tests/Output/WriterTest.php +++ b/tests/Output/WriterTest.php @@ -118,11 +118,11 @@ public function test_terminal() $this->assertInstanceOf(Terminal::class, (new Writer)->terminal()); } - public function test_two_column_detail() + public function test_justify() { $w = new Writer(static::$ou); - $w->twoColumnDetail('PHP Version', PHP_VERSION, [ + $w->justify('PHP Version', PHP_VERSION, [ 'sep' => '-' ]);