3

I love admin-menu's Enable Developer Modules menu item. How can I toggle this from the command line?

Admin menu already has a configuration of "developer" modules set up in settings.php. I can access this array with drush vget admin_menu_devel_modules (well sort of, that returns two entries). Now I want to 'pipe' those items to drush enable. I know that's not literally possible but this is my thought process.

How can I script this command?

5 Answers 5

4

I prefer to have a custom module that has dependencies for all the developer modules I need. I also set up this module to have some strongarmed variables (such as turning off preprocessing of css/js and any page caching), and enables a few developer blocks using Context (such as execute php and context inspector). This allows you to simply drush en/dis the one module to turn on/off all of your developer utilities.

Here's my Lullabot devel module that you can look at for an example.

1
  • Great idea! Elegant way of solving this.
    – ack
    Mar 20, 2011 at 6:05
1

The cleanest option might be to write your own Drush command from scratch. They don't have to be terribly complicated -- the 'sandwich' command is installed with Drush and serves as a nice template.

1

Another possibility for those who use a building framework like ant or phing is to define a target in your build.xml file with all the task that you need to perform to set up your perfect dev environment. Another target can be defined to undo the first. That way you can toggle between the two modes at will.

A brief example of such targets are below

   <target name="en-dev">
      <exec  command="drush --yes en devel devel_themer coder"  />
      <exec  command="drush --yes perm-grant 'Authenticated User' 'access devel'" />
      <exec  command="drush --yes perm-grant 'Annonymous User' 'access devel'" />
    </target>

    <target name="dis-dev">
      <exec  command="drush --yes dis devel devel_themer coder"  />
      <exec  command="drush --yes perm-revoke 'Authenticated User' 'access devel'" />
      <exec  command="drush --yes perm-revoke 'Annonymous User' 'access devel'" />
    </target>

In this case I could run phing en-dev to set up my dev environment.

For the opposite function I just run phing dis-dev

0

Not tested with this situation but xargs can take the results of one command and pipe as arguments to the next

drush vget admin_menu_devel_modules | xargs drush en  

you may need to do a bit of sed in the middle if the variable that vget returns is not to drush en's liking.

0
drush pm-enable `drush php-eval "echo 'ctools'"`

This would try to enable ctools; change echo ctools to one that formats the modules with a spaces between them

1
  • Use an alternative to backtick? drush pm-enable $(drush php-eval "echo 'ctools'")?
    – user413
    Mar 16, 2011 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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