public function list_( $args, $assoc_args ) {
		$formatter = $this->get_formatter( $assoc_args );

		if ( 'ids' === $formatter->format ) {
			$assoc_args['fields'] = 'comment_ID';
		}

		$assoc_args = self::process_csv_arguments_to_arrays( $assoc_args );

		if ( 'count' === $formatter->format ) {
			$assoc_args['count'] = true;
		}

		if ( ! empty( $assoc_args['comment__in'] )
			&& ! empty( $assoc_args['orderby'] )
			&& 'comment__in' === $assoc_args['orderby']
			&& Utils\wp_version_compare( '4.4', '<' ) ) {
			$comments = [];
			foreach ( $assoc_args['comment__in'] as $comment_id ) {
				$comment = get_comment( $comment_id );
				if ( $comment ) {
					$comments[] = $comment;
				} else {
					WP_CLI::warning( "Invalid comment {$comment_id}." );
				}
			}
		} else {
			$query    = new WP_Comment_Query();
			$comments = $query->query( $assoc_args );
		}

		if ( 'count' === $formatter->format ) {
			echo $comments;
		} else {
			if ( 'ids' === $formatter->format ) {
				$comments = wp_list_pluck( $comments, 'comment_ID' );
			} elseif ( is_array( $comments ) ) {
				$comments = array_map(
					function( $comment ) {
							$comment->url = get_comment_link( $comment->comment_ID );
							return $comment;
					},
					$comments
				);
			}
			$formatter->display_items( $comments );
		}
	}
public function list_( $args, $assoc_args ) {
		$formatter = $this->get_formatter( $assoc_args );

		if ( 'ids' === $formatter->format ) {
			$assoc_args['fields'] = 'comment_ID';
		}

		$assoc_args = self::process_csv_arguments_to_arrays( $assoc_args );

		if ( 'count' === $formatter->format ) {
			$assoc_args['count'] = true;
		}

		if ( ! empty( $assoc_args['comment__in'] )
			&& ! empty( $assoc_args['orderby'] )
			&& 'comment__in' === $assoc_args['orderby']
			&& Utils\wp_version_compare( '4.4', '<' ) ) {
			$comments = [];
			foreach ( $assoc_args['comment__in'] as $comment_id ) {
				$comment = get_comment( $comment_id );
				if ( $comment ) {
					$comments[] = $comment;
				} else {
					WP_CLI::warning( "Invalid comment {$comment_id}." );
				}
			}
		} else {
			$query    = new WP_Comment_Query();
			$comments = $query->query( $assoc_args );
		}

		if ( 'count' === $formatter->format ) {
			echo $comments;
		} else {
			if ( 'ids' === $formatter->format ) {
				$comments = wp_list_pluck( $comments, 'comment_ID' );
			} elseif ( is_array( $comments ) ) {
				$comments = array_map(
					function( $comment ) {
							$comment->url = get_comment_link( $comment->comment_ID );
							return $comment;
					},
					$comments
				);
			}
			$formatter->display_items( $comments );
		}
	}
public function list_ ( $ args , $ assoc_args ) { $ formatter = $ this -> get_formatter ( $ assoc_args ) ; if ( 'ids' === $ formatter -> format ) { $ assoc_args [ 'fields' ] = 'comment_ID' ; } $ assoc_args = self :: process_csv_arguments_to_arrays ( $ assoc_args ) ; if ( 'count' === $ formatter -> format ) { $ assoc_args [ 'count' ] = true ; } if ( ! empty ( $ assoc_args [ 'comment__in' ] ) && ! empty ( $ assoc_args [ 'orderby' ] ) && 'comment__in' === $ assoc_args [ 'orderby' ] && Utils \ wp_version_compare ( '4.4' , '<' ) ) { $ comments = [ ] ; foreach ( $ assoc_args [ 'comment__in' ] as $ comment_id ) { $ comment = get_comment ( $ comment_id ) ; if ( $ comment ) { $ comments [ ] = $ comment ; } else { WP_CLI :: warning ( "Invalid comment {$comment_id}." ) ; } } } else { $ query = new WP_Comment_Query ( ) ; $ comments = $ query -> query ( $ assoc_args ) ; } if ( 'count' === $ formatter -> format ) { echo $ comments ; } else { if ( 'ids' === $ formatter -> format ) { $ comments = wp_list_pluck ( $ comments , 'comment_ID' ) ; } elseif ( is_array ( $ comments ) ) { $ comments = array_map ( function ( $ comment ) { $ comment -> url = get_comment_link ( $ comment -> comment_ID ) ; return $ comment ; } , $ comments ) ; } $ formatter -> display_items ( $ comments ) ; } }
Gets a list of comments.

Display comments based on all arguments supported by
[WP_Comment_Query()](https://developer.wordpress.org/reference/classes/WP_Comment_Query/__construct/).

## OPTIONS

[--<field>=<value>]
: One or more args to pass to WP_Comment_Query.

[--field=<field>]
: Prints the value of a single field for each comment.

[--fields=<fields>]
: Limit the output to specific object fields.

[--format=<format>]
: Render output in a particular format.
---
default: table
options:
- table
- ids
- csv
- json
- count
- yaml
---

## AVAILABLE FIELDS

These fields will be displayed by default for each comment:

* comment_ID
* comment_post_ID
* comment_date
* comment_approved
* comment_author
* comment_author_email

These fields are optionally available:

* comment_author_url
* comment_author_IP
* comment_date_gmt
* comment_content
* comment_karma
* comment_agent
* comment_type
* comment_parent
* user_id
* url

## EXAMPLES

# List comment IDs.
$ wp comment list --field=ID
22
23
24

# List comments of a post.
$ wp comment list --post_id=1 --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 1          | 2015-06-20 09:00:10 | Mr WordPress   |
+------------+---------------------+----------------+

# List approved comments.
$ wp comment list --number=3 --status=approve --fields=ID,comment_date,comment_author
+------------+---------------------+----------------+
| comment_ID | comment_date        | comment_author |
+------------+---------------------+----------------+
| 1          | 2015-06-20 09:00:10 | Mr WordPress   |
| 30         | 2013-03-14 12:35:07 | John Doe       |
| 29         | 2013-03-14 11:56:08 | Jane Doe       |
+------------+---------------------+----------------+

@subcommand list
Gets a list of comments .