These are three related proposals to improve pm-download and pm-enable interaction.
1. Extend this to allow choosing which extensions to enable from given projects.
drush pm-enable --projects="views,cck"
Please select the modules you want to enable, separated by commas:
[0] cancel
[1] views
[2] views_ui
[3] content
[4] text
[5] number
[6] nodereference...
2. After downloading some projects, have a change to enable extensions from them. This is to be built upon point 1.
drush dl views cck --enable
Please select the modules you want to enable, separated by commas:
[0] cancel
[1] views
[2] views_ui
[3] content
[4] text
[5] number
[6] nodereference...
3. Extend pm-enable to offer to download the project for a missing extension. At present it only downloads missing dependencies.
$ drush en views cpn
views was not found. [warning]
cpn was not found. [warning]
Would you like to download the missing projects? (y/n): y
Project views (7.x-3.0) downloaded to sites/all/modules/views. [ok]
Project cpn (7.x-1.4) downloaded to sites/all/modules/cpn. [ok]
The following extensions will be enabled: views, cpn
Do you really want to continue? (y/n): y
cpn was enabled successfully. [ok]
views was enabled successfully. [ok]
It can be done with drush_choice_multiple().
The multichoice is to be implemented by leveraging drush_choice_multiple.
Comments
Comment #1
robloachWhat if there was something like this.......
Comment #2
greg.1.anderson commentedYeah, I was going to suggest the same thing.
drush enwill already try to find dependencies; it should also try to find the projects for the modules requested if they do not exist per #1.n.b. the "find dependencies" feature was broken by pmtng, but it's probably a small fix to get it back.
Comment #3
elijah lynnIn addition to #1 by Rob Loach:
and
Comment #3.0
elijah lynnPut together "An other" to make "Another"
Comment #4
jonhattanJust updated the initial proposal to reflect the three options. I'm not keen to introduce a new command. User can choose to configure default behaviour for a command. For example:
Comment #5
luksakI would love this!
Comment #6
frobYes, this would be awesome.
Comment #7
eiriksmHere is a really simple implementation of this. It just tries to download the projects it can not find. I already have something like this in a bash script, but found this issue while trying to see if others had any implementations of it. So why not try to get it commited to drush core.
Command output following. First let's try something simple:
An example with dependencies:
And an example where the project does not exists:
Here is an example of a mixture between a project with dependencies and a project that does not exists:
As you can see, the warning of not found pops up twice. Not sure how to avoid that when dealing with dependencies. Also, I find it quite OK that i can see it almost at the end also that something went wrong.
Lastly, here is an example of enabling an already downloaded example (with a dependency just to be cool):
Please review. Would be an awesome feature to have!
Comment #8
eiriksmComment #9
greg.1.anderson commentedI like #7 better than item 2 in the O.P. Haven't tried the patch, but the code looks pretty good. I'm indifferent about whether unknown stuff should fail fast, or just keep going per the current implementation. If id doesn't fail fast, warning twice is okay.
Could use a test.
Comment #10
luksakWorks for me. Thank you!
Comment #11
eiriksmThanks for reviewing.
New patch, now including a simple test as well.
Comment #12
eiriksm...or maybe like this, so we do more like the code comment say we do.
Comment #13
moshe weitzman commentedSorry this got lost. Hopefully jonhattan can have a look, and others can review. I'm not that hot on compound commands anymore but this one sure is useful.
Comment #14
eiriksmSounds good. Since I noticed you changed branch for this, I just verified the patch still applies to 8.x-6.x-dev.
Just out of curiosity: Is there a reason this can not get in 5.x?
Comment #15
greg.1.anderson commentedThe policy is that all new patches go in 8.x-6.x first, and patches that are backported to 7.x-5.x cannot break or change existing functionality. Therefore, this patch could go into 7.x-5.x, as it extends but does not change existing behavior.
Comment #16
jonhattanAfter applying patch in #12 I saw the oportunity for a refactorization and the resulting code seems more compact. I'll commit the attached patch tomorrow if no objections.
Comment #17
greg.1.anderson commentedSure, looks fine. The
drush_set_context('DRUSH_AFFIRMATIVE', FALSE);still bugs me; it would be better to set a backend option that cleared the --yes flag in backend invoke. Feel free to ignore that, or open a new issue for it and assign it to me.Comment #18
moshe weitzman commentedLooks good to me. I set the title to what the current patch actually does (as far as I can tell)
Comment #19
jonhattanCommitted #16 to drush 6.x and 5.x. It implements 3rd proposal in OP. Setting title in concordance.
Issue for the other proposal in OP: #1985072: Allow to enable extensions after dl project
Issue to not pass --yes to backend calls per #17: #1985068: Add a backend option to not propagate --yes
Comment #20.0
(not verified) commentedSumarize all the points