From: scribu Date: Thu, 9 May 2013 17:53:47 +0000 (+0300) Subject: first pass at --verbose flag for `wp export` X-Git-Tag: v0.10.0~56^2~5 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=32402827d8e738c7c4e6025b7b3bbc6d7a1a45d2;p=wvm%2Fwvm.git first pass at --verbose flag for `wp export` --- diff --git a/php/commands/export.php b/php/commands/export.php index 0f85c92c..2983053d 100644 --- a/php/commands/export.php +++ b/php/commands/export.php @@ -11,7 +11,7 @@ class Export_Command extends WP_CLI_Command { /** * Export content to a WXR file. * - * @synopsis [--dir=] [--start_date=] [--end_date=] [--post_type=] [--post_status=] [--post__in=] [--author=] [--category=] [--skip_comments] [--file_item_count=] + * @synopsis [--dir=] [--start_date=] [--end_date=] [--post_type=] [--post_status=] [--post__in=] [--author=] [--category=] [--skip_comments] [--file_item_count=] [--verbose] */ public function __invoke( $_, $assoc_args ) { $defaults = array( @@ -25,6 +25,7 @@ class Export_Command extends WP_CLI_Command { 'post__in' => NULL, 'skip_comments' => NULL, 'file_item_count' => 1000, + 'verbose' => false, ); $args = wp_parse_args( $assoc_args, $defaults ); @@ -51,6 +52,12 @@ class Export_Command extends WP_CLI_Command { $this->export_wp( $this->export_args ); } + private function check_verbose( $verbose ) { + $this->verbose = $verbose; + + return true; + } + private function check_dir( $path ) { if ( empty( $path ) ) { $this->export_args['dir'] = getcwd(); @@ -376,7 +383,8 @@ class Export_Command extends WP_CLI_Command { WP_CLI::line( 'Writing to file ' . $full_path ); } - $progress = new \cli\progress\Bar( 'Exporting', count( $post_ids ) ); + if ( !$this->verbose ) + $progress = new \cli\progress\Bar( 'Exporting', count( $post_ids ) ); $this->start_export(); echo '\n"; @@ -447,7 +455,11 @@ class Export_Command extends WP_CLI_Command { // Begin Loop foreach ( $posts as $post ) { - $progress->tick(); + if ( !$this->verbose ) { + $progress->tick(); + } else { + WP_CLI::line( "Exporting post $post->ID" ); + } setup_postdata( $post ); $is_sticky = is_sticky( $post->ID ) ? 1 : 0; @@ -525,7 +537,11 @@ class Export_Command extends WP_CLI_Command { $this->flush_export( $full_path ); $this->end_export(); $this->stop_the_insanity(); - $progress->finish(); + + if ( !$this->verbose ) { + $progress->finish(); + } + $file_count++; } WP_CLI::success( "All done with export" );