diff --git a/features/post.feature b/features/post.feature index d9e5e07933..b503ccee37 100644 --- a/features/post.feature +++ b/features/post.feature @@ -100,7 +100,7 @@ Feature: Manage WordPress posts """ This is some bunkum. """ - + When I run `wp post url 1 {POST_ID}` Then STDOUT should be: """ @@ -176,6 +176,12 @@ Feature: Manage WordPress posts | Publish post | publish-post | publish | | Draft post | | draft | + When I run `wp post list --post_type='post' --fields="title, name, status" --format=csv` + Then STDOUT should be CSV containing: + | post_title | post_name | post_status | + | Publish post | publish-post | publish | + | Draft post | | draft | + When I run `wp post list --post__in={POST_ID} --format=count` Then STDOUT should be: """ diff --git a/php/WP_CLI/Formatter.php b/php/WP_CLI/Formatter.php index 87f81c8bb5..0b04ec5e81 100644 --- a/php/WP_CLI/Formatter.php +++ b/php/WP_CLI/Formatter.php @@ -40,6 +40,8 @@ public function __construct( &$assoc_args, $fields = null, $prefix = false ) { $format_args['fields'] = explode( ',', $format_args['fields'] ); } + $format_args['fields'] = array_map( 'trim', $format_args['fields'] ); + $this->args = $format_args; $this->prefix = $prefix; }