You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Set column alignment in table-formatted output #206
Describe your use case and the problem you are facing
I'd like to be able to set the alignment of table values when the --format parameter is set to "table."
Here's the output of a custom command I created, which calculates folder sizes, with the current default table column alignment (which is left-aligned):
After perusing the WP-CLI source, it appears there are references to alignment in the Formatter object.
One thing that's unclear to me is the syntax one would use to specify the desired alignments on the command line.
Here's one possibility, where a field position corresponds to the alignment position (the first --fields parameter, "title," corresponds to the first --alignments parameter, "left"):
wp plugin list --fields=title,version --alignments=left,right
Here's another syntactic possibility using a colon as a delimiter between field names and desired alignments:
wp plugin list --fields=title:left,version:right
It's more compact and easier to read, in my opinion.
When the --format parameter is not set to "table," the alignment directives should be ignored.
Activity
swissspidy commentedon Jan 28, 2026
Yeah I just merged alignment support last week, see wp-cli/php-cli-tools#192 and wp-cli/wp-cli#5934.
It's not something that you as a user control. Instead, the command developer specifies the alignment. See wp-cli/db-command#252 for an example.
So in your custom command you would specify that the size column is always right-aligned.
I don't see why a user would ever want a different alignment, but happy to be proven otherwise.
baizmandesign commentedon Jan 28, 2026
@swissspidy Oh, this is perfect! (And perfect timing!) Is this part of the next WP-CLI release (2.13.0)? If not, when can I use it in my own projects?
No need for users to control the alignment. At least, I can't think of a compelling reason when a user would want to intentionally misalign data.
swissspidy commentedon Jan 28, 2026
Yes this will be in the next release!
baizmandesign commentedon Jan 28, 2026
@swissspidy Fantastic! Thanks again. :-)