Skip to content

Commit f586e09

Browse files
Fix support for --grant=false argument (#59)
1 parent 80e2367 commit f586e09

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

features/cap.feature

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Feature: Manage Cap
2020
Success: Added 1 capability to 'contributor' role.
2121
"""
2222

23-
When I run `wp cap add contributor behold observe`
23+
When I run `wp cap add contributor behold observe --grant`
2424
Then STDOUT should contain:
2525
"""
2626
Success: Added 2 capabilities to 'contributor' role.
@@ -38,6 +38,12 @@ Feature: Manage Cap
3838
Success: Added 2 capabilities to 'contributor' role as false.
3939
"""
4040

41+
When I run `wp cap add contributor inspire --grant=false`
42+
Then STDOUT should contain:
43+
"""
44+
Success: Added 1 capability to 'contributor' role as false.
45+
"""
46+
4147
When I run `wp cap list contributor`
4248
Then STDOUT should contain:
4349
"""

src/Capabilities_Command.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ public function add( $args, $assoc_args ) {
138138

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

141-
$grant = ! isset( $assoc_args['grant'] ) || ! empty( $assoc_args['grant'] );
141+
$grant = true;
142+
if ( isset( $assoc_args['grant'] ) ) {
143+
$grant = ! $assoc_args['grant'] || 'false' === $assoc_args['grant'] ? false : true;
144+
}
142145

143146
$count = 0;
144147

0 commit comments

Comments
 (0)