28

I understand using 'drush fu' to look for changes to any components of an existing feature, but is there a way to add a component to an existing feature using drush? Right now I have to use the /admin tools to recreate, download the files, upload, etc. Would be nice if there was a way to do this process via drush.

38

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.

Update:

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

  • This doesn't seem to work with user permission and drush 5. – gagarine Aug 5 '12 at 21:37
  • Thanks for your answer! I was unable to load the re-create page in the UI for one of my site's features, and the only way to update it or add new components is via drush fc / drush fu—and it's way faster besides, which is a win in my book. – geerlingguy Jul 11 '13 at 14:15
  • does anyone have a drush command or anything to change the fc format to info file format ? BTW the " arent needed afaik – mojzis Apr 23 '14 at 8:56
16

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.

  • Interesting, that's cool. – tkrajcar Mar 7 '12 at 0:44
  • Just to note that features add is deprecated. Use features-export instead. – forest Sep 26 '12 at 13:35
4

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.

2

It's worth noting that quotes are required for permissions that have spaces in them. For example drush fe fcc_user_config user_permission:"edit own content_type content"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.