Skip to content

add --show-grant argument to wp cap list and --grant to wp cap add#19

Merged
schlessera merged 5 commits intowp-cli:masterfrom
kshaner:master
Apr 19, 2018
Merged

add --show-grant argument to wp cap list and --grant to wp cap add#19
schlessera merged 5 commits intowp-cli:masterfrom
kshaner:master

Conversation

@kshaner
Copy link
Copy Markdown
Contributor

@kshaner kshaner commented Mar 8, 2018

Addresses #18

@schlessera schlessera added command:cap-add Related to 'cap add' command command:cap-list Related to 'cap list' command labels Apr 10, 2018
@schlessera schlessera added this to the 1.0.6 milestone Apr 10, 2018
Copy link
Copy Markdown
Member

@schlessera schlessera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @kshaner!
The code looks good, I just requested changes for a lot of nitpicky things like code style and comments.

* ---
*
* [--show-grant]
* : Display all capabilites defined for role including grant
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: capabilites => capabilities

public function list_( $args, $assoc_args ) {
$role_obj = self::get_role( $args[0] );

$show_grant = !empty( $assoc_args['show-grant'] );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style: space after !

}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style: Unneeded indentation

public function add( $args, $assoc_args ) {
self::persistence_check();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style: Unneeded indentation


foreach ( $args as $cap ) {
if ( !$role_obj->has_cap( $cap ) )
if ( !isset( $role_obj->capabilities[ $cap ] ) )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style: space after !


$role_obj = self::get_role( $role );

$grant = !isset( $assoc_args['grant'] ) || !empty( $assoc_args['grant'] );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style: space after !

* ---
*
* [--show-grant]
* : Display all capabilites defined for role including grant
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Style: Comment should end with a period: .

* : One or more capabilities to add.
*
* [--grant]
* : Add the capability as true/false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Style: Comment should end with a period: .

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd reword this to make it clearer.
How about:

Adds the capability as an explicit boolean value, instead of implicitly defaulting to `true`.

@kshaner
Copy link
Copy Markdown
Contributor Author

kshaner commented Apr 11, 2018

Thanks @schlessera. I've addressed the spacing and agree with your updated comment. It looks like the travis-ci build ran out of memory on the check though. Not sure how I can address that.

@schlessera
Copy link
Copy Markdown
Member

@kshaner Thanks for the good work on this.

I've fixed the memory issue for the Travis 5.3 branch. If you merge the latest changes from master, the tests should pass.

@kshaner
Copy link
Copy Markdown
Contributor Author

kshaner commented Apr 19, 2018

@schlessera, Thanks for fixing the php memory limit. All checks pass now!

@schlessera schlessera merged commit 334ccef into wp-cli:master Apr 19, 2018
schlessera added a commit that referenced this pull request Jan 5, 2022
add --show-grant argument to wp cap list and --grant to wp cap add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:cap-add Related to 'cap add' command command:cap-list Related to 'cap list' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants