Skip to content

Commit 801c24f

Browse files
Use --include_ignored_paths=<paths> to include additional ignored paths
1 parent 8623ff9 commit 801c24f

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

features/find.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,22 @@ Feature: Find WordPress installs on the filesystem
198198
"""
199199
3
200200
"""
201+
202+
Scenario: Use --include_ignored_paths=<paths> to include additional ignored paths
203+
Given a WP install in 'subdir1'
204+
And a WP install in 'subdir2'
205+
206+
When I run `wp eval --skip-wordpress 'echo realpath( getenv( "RUN_DIR" ) );'`
207+
Then save STDOUT as {TEST_DIR}
208+
209+
When I run `wp find {TEST_DIR} --format=count`
210+
Then STDOUT should be:
211+
"""
212+
2
213+
"""
214+
215+
When I run `wp find {TEST_DIR} --include_ignored_paths='/subdir1/,/apple/' --format=count`
216+
Then STDOUT should be:
217+
"""
218+
1
219+
"""

src/Find_Command.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class Find_Command {
141141
* [--skip-ignored-paths]
142142
* : Skip the paths that are ignored by default.
143143
*
144+
* [--include_ignored_paths=<paths>]
145+
* : Include additional ignored paths as CSV (e.g. '/sys-backup/,/temp/').
146+
*
144147
* [--max_depth=<max-depth>]
145148
* : Only recurse to a specified depth, inclusive.
146149
*
@@ -174,6 +177,9 @@ public function __invoke( $args, $assoc_args ) {
174177
WP_CLI::error( 'Invalid path specified.' );
175178
}
176179
$this->skip_ignored_paths = Utils\get_flag_value( $assoc_args, 'skip-ignored-paths' );
180+
if ( ! empty( $assoc_args['include_ignored_paths'] ) ) {
181+
$this->ignored_paths = array_merge( $this->ignored_paths, explode( ',', $assoc_args['include_ignored_paths'] ) );
182+
}
177183
$this->max_depth = Utils\get_flag_value( $assoc_args, 'max_depth', false );
178184
$this->verbose = Utils\get_flag_value( $assoc_args, 'verbose' );
179185

0 commit comments

Comments
 (0)