Skip to content

Commit

Permalink
Merge pull request #36 from wp-cli/additional-ignored-paths
Browse files Browse the repository at this point in the history
Use `--include_ignored_paths=<paths>` to include additional ignored paths
  • Loading branch information
danielbachhuber authored Mar 17, 2017
2 parents 8623ff9 + 694aeb3 commit 44e0bf6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contr
## Using

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

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

[--include_ignored_paths=<paths>]
Include additional ignored paths as CSV (e.g. '/sys-backup/,/temp/').

[--max_depth=<max-depth>]
Only recurse to a specified depth, inclusive.

Expand Down
19 changes: 19 additions & 0 deletions features/find.feature
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,22 @@ Feature: Find WordPress installs on the filesystem
"""
3
"""

Scenario: Use --include_ignored_paths=<paths> to include additional ignored paths
Given a WP install in 'subdir1'
And a WP install in 'subdir2'

When I run `wp eval --skip-wordpress 'echo realpath( getenv( "RUN_DIR" ) );'`
Then save STDOUT as {TEST_DIR}

When I run `wp find {TEST_DIR} --format=count`
Then STDOUT should be:
"""
2
"""

When I run `wp find {TEST_DIR} --include_ignored_paths='/subdir1/,/apple/' --format=count`
Then STDOUT should be:
"""
1
"""
6 changes: 6 additions & 0 deletions src/Find_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class Find_Command {
* [--skip-ignored-paths]
* : Skip the paths that are ignored by default.
*
* [--include_ignored_paths=<paths>]
* : Include additional ignored paths as CSV (e.g. '/sys-backup/,/temp/').
*
* [--max_depth=<max-depth>]
* : Only recurse to a specified depth, inclusive.
*
Expand Down Expand Up @@ -174,6 +177,9 @@ public function __invoke( $args, $assoc_args ) {
WP_CLI::error( 'Invalid path specified.' );
}
$this->skip_ignored_paths = Utils\get_flag_value( $assoc_args, 'skip-ignored-paths' );
if ( ! empty( $assoc_args['include_ignored_paths'] ) ) {
$this->ignored_paths = array_merge( $this->ignored_paths, explode( ',', $assoc_args['include_ignored_paths'] ) );
}
$this->max_depth = Utils\get_flag_value( $assoc_args, 'max_depth', false );
$this->verbose = Utils\get_flag_value( $assoc_args, 'verbose' );

Expand Down

0 comments on commit 44e0bf6

Please sign in to comment.