Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alignment functionality to tables #252

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use WP_CLI\Formatter;
use WP_CLI\Utils;
use cli\table\Column;

/**
* Performs basic database operations using credentials stored in wp-config.php.
Expand Down Expand Up @@ -1145,7 +1146,6 @@ public function size( $args, $assoc_args ) {
if ( ! empty( $size_format ) && ! $tables && ! $format && ! $human_readable && true !== $all_tables && true !== $all_tables_with_prefix ) {
WP_CLI::line( str_replace( " {$size_format_display}", '', $rows[0]['Size'] ) );
} else {

// Sort the rows by user input
if ( $orderby ) {
usort(
Expand All @@ -1166,7 +1166,8 @@ function ( $a, $b ) use ( $order, $orderby ) {

// Display the rows.
$args = [
'format' => $format,
'format' => $format,
'alignments' => [ 'Size' => Column::ALIGN_RIGHT ],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we apply this only when ! WP_CLI\Utils\isPiped()? If someone is piping table output to a script right now, this could break their parsing.

Also, this is currently blocked by wp-cli/php-cli-tools#171

];

$formatter = new Formatter( $args, $fields );
Expand Down
Loading