src/Capabilities_Command.php
public function list_( $args, $assoc_args ) {
		$role_obj = self::get_role( $args[0] );

		$show_grant = ! empty( $assoc_args['show-grant'] );

		if ( $show_grant ) {
			array_push( $this->fields, 'grant' );
			$capabilities = $role_obj->capabilities;
		} else {
			$capabilities = array_filter( $role_obj->capabilities );
		}

		$output_caps = array();
		foreach ( $capabilities as $cap => $grant ) {
			$output_cap = new stdClass();

			$output_cap->name  = $cap;
			$output_cap->grant = $grant ? 'true' : 'false';

			$output_caps[] = $output_cap;
		}

		if ( 'list' === $assoc_args['format'] ) {
			foreach ( $output_caps as $cap ) {
				if ( $show_grant ) {
					WP_CLI::line( implode( ',', array( $cap->name, $cap->grant ) ) );
				} else {
					WP_CLI::line( $cap->name );
				}
			}
		} else {
			$formatter = new Formatter( $assoc_args, $this->fields );
			$formatter->display_items( $output_caps );
		}
	}
public function list_( $args, $assoc_args ) {
		$role_obj = self::get_role( $args[0] );

		$show_grant = ! empty( $assoc_args['show-grant'] );

		if ( $show_grant ) {
			array_push( $this->fields, 'grant' );
			$capabilities = $role_obj->capabilities;
		} else {
			$capabilities = array_filter( $role_obj->capabilities );
		}

		$output_caps = array();
		foreach ( $capabilities as $cap => $grant ) {
			$output_cap = new stdClass();

			$output_cap->name  = $cap;
			$output_cap->grant = $grant ? 'true' : 'false';

			$output_caps[] = $output_cap;
		}

		if ( 'list' === $assoc_args['format'] ) {
			foreach ( $output_caps as $cap ) {
				if ( $show_grant ) {
					WP_CLI::line( implode( ',', array( $cap->name, $cap->grant ) ) );
				} else {
					WP_CLI::line( $cap->name );
				}
			}
		} else {
			$formatter = new Formatter( $assoc_args, $this->fields );
			$formatter->display_items( $output_caps );
		}
	}
public function list_ ( $ args , $ assoc_args ) { $ role_obj = self :: get_role ( $ args [ 0 ] ) ; $ show_grant = ! empty ( $ assoc_args [ 'show-grant' ] ) ; if ( $ show_grant ) { array_push ( $ this -> fields , 'grant' ) ; $ capabilities = $ role_obj -> capabilities ; } else { $ capabilities = array_filter ( $ role_obj -> capabilities ) ; } $ output_caps = array ( ) ; foreach ( $ capabilities as $ cap => $ grant ) { $ output_cap = new stdClass ( ) ; $ output_cap -> name = $ cap ; $ output_cap -> grant = $ grant ? 'true' : 'false' ; $ output_caps [ ] = $ output_cap ; } if ( 'list' === $ assoc_args [ 'format' ] ) { foreach ( $ output_caps as $ cap ) { if ( $ show_grant ) { WP_CLI :: line ( implode ( ',' , array ( $ cap -> name , $ cap -> grant ) ) ) ; } else { WP_CLI :: line ( $ cap -> name ) ; } } } else { $ formatter = new Formatter ( $ assoc_args , $ this -> fields ) ; $ formatter -> display_items ( $ output_caps ) ; } }
Lists capabilities for a given role.

## OPTIONS

<role>
: Key for the role.

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

[--show-grant]
: Display all capabilities defined for a role including grant.
---
default: false
---

## EXAMPLES

# Display alphabetical list of Contributor capabilities.
$ wp cap list 'contributor' | sort
delete_posts
edit_posts
level_0
level_1
read

@subcommand list
Lists capabilities for a given role .