Use drush to add a component to a feature like a drupal pro

Features is one of those modules we can not do without. One annoying issue with features is that it is slow. The bigger the drupal site, the slower the features UI pages load. And waiting for the page to load is one of the most disturbing things during drupal development.

Adding a new component to a feature is a multistep process: Go the features page, add the component to the feature, download the feature, remove the old feature and extract the new one. And repeat many times during the day.

Fortunately, we can speed this process quite a bit. Drush to the rescue again! This post will explain how to use drush to add new components to a feature.

Add a component to a feature with drush

We can use drush to add component to a feature using the features-export command.

Here is the command help information:

➜ drush help feExport a feature from your site into a module. If called with no arguments, display a list of available components. If called with a single argument, attempt to createa feature including the given component with the same name. The option '--destination=foo' may be used to specify the path (from Drupal root) where the feature shouldbe created. The default destination is 'sites/all/modules'. The option '--version-set=foo' may be used to specify a version number for the feature or the option'--version-increment' may also to increment the feature's version number.

Arguments: feature Feature name to export. components Patterns of components to include, see features-components for the format of patterns.

Options: --destination Destination path (from Drupal root) of the exported feature. Defaults to 'sites/all/modules'. --version-increment Increment the feature's version number. --version-set Specify a version number for the feature.

Aliases: fe

Assuming you have a view called content_list and a feature called f_registration_views, here is how you add the view to the feature.:drush fe -y f_registration_views views_view:content_list --version-increment
If the feature above does not exist, it will be created.

That's great. But how do you add a content type, or a rule to a feature? We need to know what components are available and the sources for each component:.

LIst the components avaiable

There is another drush command that lists all the component in a drupal site. :

The above says that there are 2 content types in the system: article and page. Additionally, the page content type is already contained in a the f_registrations_content_types feature. To add the article content type the the same feature use drush fe egain: