-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Feature Request
- Yes, I reviewed the contribution guidelines.
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):
+------------------+--------+
| Core Directories | Size |
+------------------+--------+
| mu-plugins | 8.0K |
| plugins | 627.6M |
| themes | 89.1M |
| uploads | 309.2M |
+------------------+--------+
Because the output in the Size column is numerical, it would be easier to read if it were right-aligned, like so:
+------------------+--------+
| Core Directories | Size |
+------------------+--------+
| mu-plugins | 8.0K |
| plugins | 627.6M |
| themes | 89.1M |
| uploads | 309.2M |
+------------------+--------+
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.