Question

I am using Drush 10.3.6.

Drush config:status gives me:

# drush config:status
 --------------------------------- ------------ 
  Name                              State       
 --------------------------------- ------------ 
  webform.settings                  Different   
  webform.webform.contact           Only in DB  
  webform.webform.example_webform   Only in DB  
 --------------------------------- ------------ 

I am interested in filtering this to display only certain items, however the filter parameter does not work as expected:

# drush help config:status|grep Filter
  --filter[=FILTER] Filter output based on provided expression    

# drush --filter='^webform\.webform\..*$' config:status
In OperatorFactory.php line 50:
  Could not parse expression ^webform\.webform\..*$  

# drush --filter='webform.webform.*' config:status
In OperatorFactory.php line 50:
  Could not parse expression webform.webform.*  

What is format of the expression that needs to be passed to the filter parameter?

Was it helpful?

Solution

If you look at the Consolidation\Filter\OperatorFactory class mentioned with the error, you'll see documentation at the top of the Class that outlines the acceptable syntax.

**
 * Convert a simple operator expression into an Operator.
 *
 * The supported operators include:
 *
 *      key=value           Equals
 *      key*=value          Contains value
 *      key~=#regex#        Regular expression match
 *
 * It is also possible to negate the result of an operator by
 * adding a logical-not operator either before the entire expression,
 * e.g. !key=value, or before the operator, e.g. key!=value.
 *
 */

Using the above documentation as a guide, the following all work for me - examples two and three should work for your example case.

// 1. Use the *Equals* option to show only the config entity with name "webform.webform.contact"
drush --filter="name=webform.webform.contact" config:status

// 2. Use the *Contains value* option to show any config entity with name containing "webform.webform"
drush --filter="name*=webform.webform" config:status

// 3. Use the *Regular expression match* option to show any config entity with name starting with "webform.webform."
drush --filter="name~=#^webform\.webform\.*#" config:status
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top