Closed (fixed)
Project:
Drush
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
23 Apr 2010 at 09:55 UTC
Updated:
22 Jun 2010 at 02:30 UTC
Jump to comment: Most recent file
This patch adds the ability to enable or disable modules and themes by use of a 'wildcard' when specifying the module/theme name.
Using context module as an example, currently you do this:
drush en context context_ui context_contrib
to get all the context* modules enabled, this patch saves you a few keystrokes:
drush en context*
Useful?
I arrived at the party late, I only installed drush yesterday so I may not be aware of all the shortcuts and best practices.
Thanks for a great module, drush rocks!
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | drush-en-dis-wildcard-6.patch | 3.84 KB | matason |
| #16 | drush-en-dis-wildcard-5.patch | 4.61 KB | matason |
| #13 | drush-en-dis-wildcard-4.patch | 2.36 KB | matason |
| #8 | drush-en-dis-wildcard-3.patch | 2.94 KB | matason |
| #3 | drush-en-dis-wildcard-2.patch | 1.09 KB | matason |
Comments
Comment #1
matason commentedAnd the patch...
Comment #2
psynaptic commentedApplied the patch, tested and it works.
Comment #3
matason commentedAttached an improved patch, thanks to code review from @psynaptic and @snufkin :)
Comment #4
mcjim commentedThis makes perfect sense. Only been using it sine this morning and it's already become part of my workflow.
Works as expected.
Comment #5
greg.1.anderson commentedUseful, but the fact that the * has to go on the end could cause some head-scratching. Would it be possible to make it more general-purpose? Needs some documentation. Good work overall.
Comment #6
matason commentedThanks for the reviews, @greg.1.anderson can you elaborate on how you think * at the end is confusing and ideas on making it more general purpose?
Comment #7
greg.1.anderson commentedI think I could probably go with * on the end only if it was a documented limitation, but Moshe would have to agree. The reason it might be confusing is that the user, after using
drush pm-enable context*could naturally expect to also be able to usedrush pm-enable *foo*to enable a bunch of modules that happened to have a common string somewhere in the middle. This could be quite a time-waster if there was no documentation on the limitation.Even if the limitation is removed, docs are needed.
Thanks for your work.
Comment #8
matason commentedThanks for the comments, I see what you mean - I can't recall ever wishing I was able to enable/disable modules using some sort of *foo* criteria (maybe some people do and as you rightly point out it could be a time waster for someone) however within 2 mins of installing drush and using it to dl views and context I was looking for an option such as 'drush en views* context*'
I guess it's partly because when you download views you get not only views but views_ui and views_export that I wanted some easy way to switch them all on without having to name the sub modules explicitly.
I agree on the point about documentation so in the attached patch I've added some lines and examples to hook_drush_help().
Do you think that is sufficient or is there more I could do on documentation?
Comment #9
moshe weitzman commentedCode looks fine.
Sorry to scope creep, but we need consistency across commands. Lets identify which other commands would need same functionality
Comment #10
matason commentedGood thinking Moshe, I'll have a look through the commands and identify which would benefit from this.
Comment #11
greg.1.anderson commentedThis would be applicable to pm-disable, pm-info, pm-update, pm-updatecode and pm-uninstall.
Comment #12
matason commentedThanks @greg.1.anderson - I've been rummaging through drush code looking at these commands and so far it seems to me that they fall into two distinct types, commands that operate on the project release information (i.e. the 'main' module like views or context etc) and commands that can take (sometimes optional) a space separated list of module/theme names to operate on. I think it's these latter commands only which might benefit from this feature.
I've been through the following commands, I tried to follow them through to the functions they are calling in Drupal and to identify how they are working and whether this feature is appropriate or even needed...
pm-disable (dis) - so this works with the patch on comment 3, although drush already adds all the dependent modules to the list of modules it will disable so assuming you have views, views_ui and views_export installed issuing:
drush pm-disable viewsproduces
The following projects will be disabled: views, views_export, views_uipm-download (dl) - I don't think anything is needed here, all sub modules are downloaded when a main module is downloaded
pm-enable (en) - works with the patch on comment 3
pm-info - I think this command would benefit from the feature, I'll work on a revised patch
pm-list (sm) - nothing needed here, the command lists all sub modules anyway
pm-refresh (rf) - doesn't take any arguments, nothing needed here
pm-releases - I haven't thoroughly followed this command through but from testing it appears to work on project release info so passing in views_ui understandably returns "No information available."
pm-uninstall - not sure about this one, I need to dig deeper but it dependent modules are uninstalled by default by Drupal? With that in mind I don't think adding this feature makes sense for this command?
pm-update (up) - not needed, like pm-releases pm-update works on the main project info only
pm-updatecode (upc) - same as pm-update
So in summary I think pm-info appears to be the only additional candidate for this feature, I'll dig deeper into pm-uninstall and see what I can find.
As ever thoughts, comments and corrections appreciated ;o)
Comment #13
matason commentedI've pulled out the code that expands the project names into it's own function so that it can be called from wherever and I've added the feature to the pm-info command as well.
Comment #14
moshe weitzman commentedLooks good to me. I wonder if jonhattan or Owen have any comments? I'll commit this soon if we get no feedback.
Comment #15
moshe weitzman commentedWe need to document the * feature for the commands that support it. It can be a sentence in the 'arguments' array.
Comment #16
matason commentedHi Moshe,
In the attached patch I've added an explanation and example in README.txt and also added to the 'arguments' array as suggested.
Comment #17
moshe weitzman commentedThanks.
Lets omit mention of this feature in the README and change the text in pm-enable and pm-disable so that it mentions modules and submodules instead of projects and subprojects. The pm-info text and the _drush_pm_expand_projects () function name can stay as is.
Comment #18
matason commentedHi Moshe,
Okay, the attached patch has the changes you mentioned.
Comment #19
moshe weitzman commentedcommitted. thanks for your persistence.
Comment #20
matason commentedThat's great, thanks Moshe.
Comment #21
jonhattanThe command description says:
You can use the * wildcard at the end of module and theme names to enable the modules and all its submodules.
I think it is not all the submodules but all modules with the specified name as a prefix. That is: views, views_ui, views_bulk_operations. The later is not a submodule of the project views.
On the other hand, a project can have submodules with a name that is not a prefix. For example cck: content, fieldgroup, nodereference,...
Comment #22
greg.1.anderson commentedYes, I agree that the message should be changed. Marking active.
Comment #23
moshe weitzman commentedSlightly improved message. Committed.