New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --filter to many commands #3718
Merged
Merged
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5b35ff4
Add --filter to pm:list
greg-1-anderson 5dc6984
Add filter-output to more commands
greg-1-anderson db64208
Add filter-output to example command and generated commands. Clean up…
greg-1-anderson 0502032
Turn off validation for 'filter' in RoleCommands, since it might be a…
greg-1-anderson 0da8fb5
Don't bother to install all of our dependencies; just install phpcs
greg-1-anderson 5f7d975
Add filter default fields for other filterable commands. These are a …
greg-1-anderson 1c5f908
Add a topic for output filters.
greg-1-anderson 6e3c273
Merge branch 'master' into output-filter
greg-1-anderson 40774ad
Make a combined topic about output formats, fields and filters.
greg-1-anderson b5c0345
Merge branch 'output-filter' of github.com:drush-ops/drush into outpu…
greg-1-anderson 1bc647c
Make @filter-output annotaton implicit if @filter-default-field annot…
greg-1-anderson 93283ad
Automatically add '@topics docs:output-formats-filters' to any comman…
greg-1-anderson 25e92dc
[ci skip] Clarify the filter comparison operators = and *= are case-i…
greg-1-anderson 0096318
[ci skip] Add a comparison between filters and grep in the output topic.
greg-1-anderson 6bf87e1
Allow the 'site:alias' command to have selectable fields.
greg-1-anderson 9dcf533
Update scenarios
greg-1-anderson 86d9967
Use stable release of output-formatters with unstuctured data support…
greg-1-anderson 9004ed9
Merge branch 'master' into output-filter
greg-1-anderson File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Output Filters | ||
============== | ||
|
||
A number of Drush commands that output tabular data support a `--filter` option that allows rows from the output to be selected with simple logic expressions. | ||
|
||
In its simplest form, the `--filter` option takes a simple string that indicates the value to filter by in the command's *default filter field*. For example, the `role:list` command's default filter field is `perms`; the output of the `role:list` command can be limited to only those roles that have a specified permission: | ||
``` | ||
$ drush role:list --filter='post comments' | ||
authenticated: | ||
label: 'Authenticated user' | ||
perms: | ||
- 'access comments' | ||
- 'access content' | ||
- 'access shortcuts' | ||
- 'access site-wide contact form' | ||
- 'access user contact forms' | ||
- 'post comments' | ||
- 'search content' | ||
- 'skip comment approval' | ||
- 'use text format basic_html' | ||
``` | ||
Note that not all commands have a default filter field. | ||
|
||
Other fields in the output may be searched by using a simple expression in the `--filter` term. For example, to list only the enabled extensions with the `pm:list` command, you could run: | ||
``` | ||
$ drush pm:list --filter='status=enabled' | ||
``` | ||
To search for fields that contain a string using the operator `*=`, or match a regular expression with the `~=` operator. For example, to find all views whose machine name contains the word "content": | ||
``` | ||
drush views:list --filter='machine-name*=content' | ||
``` | ||
To use a regular expression to find any core requirement notice whose title contains either "php" or "gd" | ||
``` | ||
drush core:requirements --filter='title~=#(php|gd)#i' | ||
``` | ||
Finally, filter expressions may also use logical-and (`&&`) or logical-or (`||`) operations to separate multiple terms. Parenthesis are not supported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,7 @@ public function entityUpdates($options = ['cache-clear' => true]) | |
* type: Type | ||
* @default-fields module,update_id,type,description | ||
* @filter-output | ||
* @filter-default-field module | ||
weitzman marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think 'type' would be a better default field here. |
||
* @return \Consolidation\OutputFormatters\StructuredData\RowsOfFields | ||
*/ | ||
public function updatedbStatus($options = ['format'=> 'table', 'entity-updates' => true, 'post-updates' => true]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this ... I have two thoughts. I don't know how to handle them though.