wp-cli / php-cli-tools

A collection of tools to help with PHP command line utilities
MIT License
671 stars 117 forks source link

setRenderer doesn't work #135

Closed joerecra closed 6 years ago

joerecra commented 6 years ago

When I use: $table->setRenderer(new \cli\table\Ascii([80, 20, 20])) or I change array values into Ascii this doesn't work, table doesn't rendered.

$table = new \cli\Table(); $table->setHeaders($headers); $table->setRows($results); $table->setRenderer(new \cli\table\Ascii([80, 20, 20])); $table->display();

Please any help I pleasure it.

captura

wojsmol commented 6 years ago

Please post wp --info from your testing environment.

joerecra commented 6 years ago

Hey @wojsmol thanks for your request this is my wp --info:

OS: Linux 4.15.0-32-generic #35-Ubuntu SMP Fri Aug 10 17:58:07 UTC 2018 x86_64 Shell: /bin/bash PHP binary: /usr/bin/php7.2 PHP version: 7.2.9-1+ubuntu18.04.1+deb.sury.org+1 php.ini used: /etc/php/7.2/cli/php.ini WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli WP-CLI vendor dir: phar://wp-cli.phar/vendor WP_CLI phar path: /home/joe WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.0.0

schlessera commented 6 years ago

@joerecra What are you trying to do with this: new \cli\table\Ascii([80, 20, 20])?

I'm not sure I fully understand what the problem is, but I'm guessing you're misinterpreting what the column widths do.

[80, 20, 20] will set the widths of the first three columns to 80, 20 and 20 respectively. It will probably produce broken and arbitrary output if you have more columns than you provide the width for.

So, either let the system just handle it automatically (new \cli\table\Ascii()), or provide as many widths as you have columns.

Let me know if I just misunderstood your report...

joerecra commented 6 years ago

Well @schlessera, Whit this: new \cli\table\Ascii([80, 20, 20]) I'm trying to set width columns in my table.

When I add one column "Empty" and remove setRenderer this automatically renderers, let's call it "good"

tablegood

But I want to set width, putting my own widths Maybe 50 or 80 or 100 whatever, I don't Know. But this doesn't work.

In last image I used: $table->setRenderer(new \cli\table\Ascii([80, 5, 20, 20, 20])); but nothing changes. Another thing, in examples dir I change widths and it doesn't work neither.

I'm confusing. Sorry

joerecra commented 6 years ago

Thank you @schlessera bug was corrected !