From 3e5d8c8a470e65081479b7785edbe5c938d75951 Mon Sep 17 00:00:00 2001 From: scribu Date: Tue, 13 Aug 2013 03:13:16 +0300 Subject: [PATCH] site list: add --format=url; see #661 --- php/commands/site.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/php/commands/site.php b/php/commands/site.php index e34fce87..285c37c3 100644 --- a/php/commands/site.php +++ b/php/commands/site.php @@ -331,12 +331,12 @@ class Site_Command extends WP_CLI_Command { * : Comma-separated list of fields to show. * * --format= - * : Output list as table, CSV, JSON. Defaults to table. + * : Output list as table, csv, json or url. Defaults to table. * * ## EXAMPLES * * # Output the list of site URLs - * wp site list --fields=domain,path --format=csv | tail -n +2 | sed 's/,//' + * wp site list --format=url * * @subcommand list * @synopsis [--network=] [--format=] [--fields=] @@ -365,7 +365,13 @@ class Site_Command extends WP_CLI_Command { ); $it = new \WP_CLI\Iterators\Table( $iterator_args ); - WP_CLI\Utils\format_items( $assoc_args['format'], $it, $assoc_args['fields'] ); + if ( 'url' == $assoc_args['format'] ) { + foreach ( $it as $blog ) { + WP_CLI::line( $blog->domain . $blog->path ); + } + } else { + WP_CLI\Utils\format_items( $assoc_args['format'], $it, $assoc_args['fields'] ); + } } } -- 2.11.0