Home / Comment permalink

Drupal CLI utils

I put together a few scripts that I needed to configure and manage drupal from CLI.

They include the following scripts:
- Installer (install.php D6 & D7)
- Updater (update.php)
- Code Coverage (working example: http://acquia.com/latest-drupal-test-results)
- Unit Test Runner (run-tests.sh)
- Module enabler

and the following library code:
- CLI arg parser
- Drupal Web Form User Agent (uses php-curl)

additional points:
- Much of the code has unit tests (simpletest, php-mock-functions w/o runkit)
- Code was designed to be extended for custom purposes.
- I work with D5 though D7 sites, although not all the scripts work on all version.
- Developed on linux, some scripts used on mac, most certainly doesn't work on windows as is.

Right now, the code can be found here
but if others are interested in using it, I would be happy to move it to a new home


Posted on by Boris Mann (not verified).

Ever consider using Drush (http://drupal.org/project/drush )? There are a bunch of other CLI util libraries floating around. See also http://drupal.org/project/p rovision

Extending drush to handle these tests would probably make for more re-usable code.

Posted on by d hubler.

i started with drush but i also started with the installer so i quickly realized i needed a running system to run drush. Once the installer was done, I could have turned back to drush for the other features, but i didn't.

The actual CLI part is abstracted out into an isolated piece of the code. That is to say, the core logic exists in separate files unaware it's running in CLI so drush support should be fairly easy.

Posted on by clemens.tolboom (not verified).

Thanks for sharing your code. I'll look into codecoverage.

Have you tried http://drupal.org/project/dr ush_mm aka Drush Module Manager? It handles dependencies quite nice and has a uninstall option too.

Btw you can run tests through drush.

drush test list

Maybe you like my drush multisite script on http:// build2be.com/en/content/froscon-2008-drupal-room (See 'Running wild on the command line')

After writing my own scripts I now stick to drush or write extensions for it. Ie I can now create nodes with drush and http://drupal.org/projec t/node_factory

drush create json '...'


Posted on by Ben Lavender (not verified).

This really made my day. Thanks!

Posted on by sdboyer (not verified).

pwolanin pointed me to the Acquia daily test results back in Szeged, and I downloaded the cli-utils you'd put together back then, but promptly forgot about them. I was reminded while listening to the latest lullacast today, though.

Since Szeged, I've fallen in love with git-sh, and had the thought that it'd be cool to turn drush into that kind of an interactive shell. Moshe agreed enthusiastically when I ran it by him, at least at the conceptual level. I think that such a project would necessarily be rooted in the 'include-a-Makefile' paradigm that you've got going on here, but might also be able seamlessly manage the transition between working with an empty directory to grabbing a fresh copy of drupal, installing it, etc.

However it ends up working, I think the direction you've gone with these tools is really nifty - that CLI arg parsing, for example, just makes me all too happy. So if I ever do find time to work on such a thing, I'd love to figure out how some (most? all?) of what you've done with these utils could fit in.

Posted on by Steve Dondley (not verified).

Great, thanks for posting this. Very timely as I'm doing an upgrade of over 100 site modules in a shot. Combined this with a simple perl script to hit all of my sites easily.

Posted on by vascot (not verified).

Nice script, only installing modules with spaces in their names doesn't work.

I like to move this project to a drupal cvs and drupal project page. Can you release it under gplv2?

Posted on by Cx (not verified).

I'd like to see Drush be enhanced to install & update Acquia Drupal, even as an add-on.

Posted on by Joshua Brauer.

Drush supports using SVN so it is possible today to use Drush to manage your Acquia Drupal checkout and updates.

It could be interesting to see drush become "distribution aware" where it could perhaps do the initial checkout from a repository of a number of distributions not housed on drupal.org.

Acquia Technical Assistance Center