WP_CLI

Formatter::show_table()private staticWP-CLI 1.0

Show items in a \cli\Table.

Method of the class: Formatter{}

No Hooks.

Return

null. Nothing.

Usage

$result = Formatter::show_table( $items, $fields, $ascii_pre_colorized );
$items(array) (required)
-
$fields(array) (required)
-
$ascii_pre_colorized(true|false|array)
A boolean or an array of booleans to pass to Table::setAsciiPreColorized() if items in the table are pre-colorized.
Default: false

Formatter::show_table() code WP-CLI 2.8.0-alpha

private static function show_table( $items, $fields, $ascii_pre_colorized = false ) {
	$table = new Table();

	$enabled = Colors::shouldColorize();
	if ( $enabled ) {
		Colors::disable( true );
	}

	$table->setAsciiPreColorized( $ascii_pre_colorized );
	$table->setHeaders( $fields );

	foreach ( $items as $item ) {
		$table->addRow( array_values( Utils\pick_fields( $item, $fields ) ) );
	}

	foreach ( $table->getDisplayLines() as $line ) {
		WP_CLI::line( $line );
	}

	if ( $enabled ) {
		Colors::enable( true );
	}
}