Drupal - Adding components to a feature via Drush

Update: there is a direct way to add components via Drush.

First, to list components drush fc (for features components) will list out all exportable components, including which, if any, feature they are currently exported to.

Next, drush fe foo_feature variable:foo_var views_view:foo_view will update, or create, a module named foo_feature. The output from drush fc can be used to populate the required component:name syntax.

Original answer

While there is no direct command, the quickest way to add components is by editing the .info file.

For example, to add a view foo_view, you would add this line:

features[views][] = "foo_view"

or, to add a variable that hadn't been added, you would add this line:

features[variable][] = "my_variable"

Once these have been added to the .info file, you can then run drush fu, and the additional components will be exported with your feature.


There is a command. See the below answer about the drush fe command.

There's been an on-going discussion about this topic, but it seems that drush features-export (drush fe) is the accepted solution.

To find the components (views, pages, etc.) you want to add to your feature, use drush features-components; this command has a relatively easy-to-use interface that should be familiar to anyone who has created Features through the admin graphical interface.

Once you've found the component you want, enter it in the pattern drush fe [feature_name] [component_name], as in the following:

drush fe feature_name views_view:user_questions

HISTORICAL INFO (deprecated)

Drush formerly used drush features-add for this functionality; the maintainers seem to have settled upon drush features-export.

drush features-add is deprecated. Use drush features-export instead. It will add components to existing features as well.

To get a list of exportable components first use

drush features-components --not-exported [pattern]

See drush features-components --help for how to use [pattern] to filter the components to be listed.