Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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.

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

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.

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a drupal.stackexchange
scroll top