Skip to content

Commit 44e0bf6

Browse files
Merge pull request #36 from wp-cli/additional-ignored-paths
Use `--include_ignored_paths=<paths>` to include additional ignored paths
2 parents 8623ff9 + 694aeb3 commit 44e0bf6

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contr
1010
## Using
1111

1212
~~~
13-
wp find <path> [--skip-ignored-paths] [--max_depth=<max-depth>] [--fields=<fields>] [--field=<field>] [--format=<format>] [--verbose]
13+
wp find <path> [--skip-ignored-paths] [--include_ignored_paths=<paths>] [--max_depth=<max-depth>] [--fields=<fields>] [--field=<field>] [--format=<format>] [--verbose]
1414
~~~
1515

1616
Recursively iterates subdirectories of provided `<path>` to find and
@@ -40,6 +40,9 @@ $ wp find ./
4040
[--skip-ignored-paths]
4141
Skip the paths that are ignored by default.
4242

43+
[--include_ignored_paths=<paths>]
44+
Include additional ignored paths as CSV (e.g. '/sys-backup/,/temp/').
45+
4346
[--max_depth=<max-depth>]
4447
Only recurse to a specified depth, inclusive.
4548

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)