public function generate( $args, $assoc_args ) {

		$defaults   = [
			'count'   => 100,
			'post_id' => 0,
		];
		$assoc_args = array_merge( $defaults, $assoc_args );

		$format = Utils\get_flag_value( $assoc_args, 'format', 'progress' );

		$notify = false;
		if ( 'progress' === $format ) {
			$notify = Utils\make_progress_bar( 'Generating comments', $assoc_args['count'] );
		}

		$comment_count = wp_count_comments();
		$total         = (int) $comment_count->total_comments;
		$limit         = $total + $assoc_args['count'];

		for ( $index = $total; $index < $limit; $index++ ) {
			$comment_id = wp_insert_comment(
				[
					'comment_content' => "Comment {$index}",
					'comment_post_ID' => $assoc_args['post_id'],
				]
			);
			if ( 'progress' === $format ) {
				$notify->tick();
			} elseif ( 'ids' === $format ) {
				echo $comment_id;
				if ( $index < $limit - 1 ) {
					echo ' ';
				}
			}
		}

		if ( 'progress' === $format ) {
			$notify->finish();
		}

	}
public function generate( $args, $assoc_args ) {

		$defaults   = [
			'count'   => 100,
			'post_id' => 0,
		];
		$assoc_args = array_merge( $defaults, $assoc_args );

		$format = Utils\get_flag_value( $assoc_args, 'format', 'progress' );

		$notify = false;
		if ( 'progress' === $format ) {
			$notify = Utils\make_progress_bar( 'Generating comments', $assoc_args['count'] );
		}

		$comment_count = wp_count_comments();
		$total         = (int) $comment_count->total_comments;
		$limit         = $total + $assoc_args['count'];

		for ( $index = $total; $index < $limit; $index++ ) {
			$comment_id = wp_insert_comment(
				[
					'comment_content' => "Comment {$index}",
					'comment_post_ID' => $assoc_args['post_id'],
				]
			);
			if ( 'progress' === $format ) {
				$notify->tick();
			} elseif ( 'ids' === $format ) {
				echo $comment_id;
				if ( $index < $limit - 1 ) {
					echo ' ';
				}
			}
		}

		if ( 'progress' === $format ) {
			$notify->finish();
		}

	}
public function generate ( $ args , $ assoc_args ) { $ defaults = [ 'count' => 100 , 'post_id' => 0 , ] ; $ assoc_args = array_merge ( $ defaults , $ assoc_args ) ; $ format = Utils \ get_flag_value ( $ assoc_args , 'format' , 'progress' ) ; $ notify = false ; if ( 'progress' === $ format ) { $ notify = Utils \ make_progress_bar ( 'Generating comments' , $ assoc_args [ 'count' ] ) ; } $ comment_count = wp_count_comments ( ) ; $ total = ( int ) $ comment_count -> total_comments ; $ limit = $ total + $ assoc_args [ 'count' ] ; for ( $ index = $ total ; $ index < $ limit ; $ index ++ ) { $ comment_id = wp_insert_comment ( [ 'comment_content' => "Comment {$index}" , 'comment_post_ID' => $ assoc_args [ 'post_id' ] , ] ) ; if ( 'progress' === $ format ) { $ notify -> tick ( ) ; } elseif ( 'ids' === $ format ) { echo $ comment_id ; if ( $ index < $ limit - 1 ) { echo ' ' ; } } } if ( 'progress' === $ format ) { $ notify -> finish ( ) ; } }
Generates some number of new dummy comments.

Creates a specified number of new comments with dummy data.

## OPTIONS

[--count=<number>]
: How many comments to generate?
---
default: 100
---

[--post_id=<post-id>]
: Assign comments to a specific post.

[--format=<format>]
: Render output in a particular format.
---
default: progress
options:
- progress
- ids
---

## EXAMPLES

# Generate comments for the given post.
$ wp comment generate --format=ids --count=3 --post_id=123
138 139 140

# Add meta to every generated comment.
$ wp comment generate --format=ids --count=3 | xargs -d ' ' -I % wp comment meta add % foo bar
Success: Added custom field.
Success: Added custom field.
Success: Added custom field.
Generates some number of new dummy comments .