Homec4science

Add a `PhutilConsoleTable` class for drawing tables.

Authored by Joshua Spence <josh@joshuaspence.com> on Jun 15 2014, 19:51.

Description

Add a PhutilConsoleTable class for drawing tables.

Summary: Currently there is no easy way to draw a table. PhabricatorDaemonManagementStatusWorkflow draws a table in an ad-hoc way, but it would be useful to provide a more flexible mechanism to do so.

Test Plan:

$table = id(new PhutilConsoleTable())
  ->addColumn('foo', array('title' => 'Foo', 'align' => 'right'))
  ->addColumn('bar', array('title' => 'Foobar', 'align' => 'center'))
  ->addColumn('baz', array('title' => '日本語'))

  ->addRow(array('foo' => 12345, 'bar' => 'foo', 'baz' => 'baz'))
  ->addRow(array('foo' => '汉语漢語', 'bar' => '한국어조선말', 'baz' => 'ру́сский язы́к'))
  ->addRow(array('foo' => 'aaa', 'bar' => '✓✗', 'baz' => 'dddddddddddd'))
  ->addRow(array('foo' => '', 'bar' => '', 'baz' => ''));

$table->setBorders(false)->draw();
echo "\n";
$table->setBorders(true)->draw();

Output
{F166929}

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9533

Details

Committed
epriestley <git@epriestley.com>Jun 15 2014, 19:51
Pushed
aubortMar 17 2017, 12:03
Parents
rPHUe57d872cbe61: Reduce the amount of information leaked into stack traces
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPHU1fa58627e797: Add a `PhutilConsoleTable` class for drawing tables. (authored by Joshua Spence <josh@joshuaspence.com>).Jun 15 2014, 19:51