Drupal Answers or What can drush do outside the admin interface?
So, the new Drupal Answers site on StackExchange has been getting tested out, and I wanted to share with the greater community that I think it's a good idea. So far, there has been some good questions, even better answers, and most importantly there has been easy and effective moderation of content by some dedicated users. Plus, there is karma! And everybody loves karma. The site is currently in private beta on StackExchange, but regardless of how you feel about an Answers site on StackExchange for Drupal, it's obvious already that there is some value there (and some really great users like Dave Reid, berdir, tim plunkett, mark trapp, and on and on).
The real value to me though is that I get a nice feedback loop going after answering questions. Getting upvotes and more karma encourages me to come back, vote on, and answer more questions. This is one of the reasons I started hanging out so much in #drupal on IRC as opposed to frequenting the forums. With the d.o. forums I sometimes don't know if the original poster is even going to ever come back and read the answer, or anybody ever will for that matter. Whereas on StackExchange (which I was skeptical of last year), it's possible not only to get feedback, but to get comments, and honestly to get my nice warm fuzzy feeling for helping others (I mean, that's why most of us are using Drupal anyways, right? Asides from my co-worker next to me who just did the evil Monty Burns laugh and said "excellent" when I showed him some of the ways Drupal can slice up data).
Anyways, on to the point, there are some great questions there, and I hope everyone will get to see them once the site goes live, which I am confident it will. In the meantime, I wanted to share an answer of mine which got a lot of upvotes. Am I tooting my own horn? Sure, but I wanted to show how we can add a bit of entertainment and fun into answering Drupal questions. I don't know if that particular original question is going to survive, but it went as follows:
I'm aware that Drush is a powerful command-line tool for managing a Drupal site. What uses have you gotten from it that go beyond what you can do in the Drupal interface?
And my answer, partially inspired by Kiva's liberal afternoon wine/beer policies (please note I am not a drush expert, there are those who could answer this better than me for sure):
This is a good question because some people question how much more effective drush can make you, and the answer is, "ninja works it".
We needed to delete all nodes of a certain content type. No, you can't just go into MySQL command line and run "delete from node;" and expect good things to happen. So we wrote a quick plugin to drush and bam
$ drush node-deletebytype article >63 nodes deleted
Can you imagine if you had do selects on the checkboxes in the admin interface for that? What if you had 6000 nodes (as we often did when importing lots of content). If you don't want to write your own plugin, the Delete All 6.x-dev version has drush integration, and there is a patch available for D7.
But wait, that's not all, you also get the great combination of using drush and piping the output to other commands like grep. Let's say I have a big development site testing out lots of new features and I can't remember all the facebook modules I'm trying out, well drush to the rescue:
$ drush pm-list | grep -i facebook Drupal for Facebook - contrib Register Users (fb_register.module) (fb_register) Module Not installed 6.x-3.0-rc3 Drupal for Facebook - contrib Rules Integration (fb_rules.module) (fb_rules) Module Not installed 6.x-3.0-rc3 Facebook connect Fbconnect Events (fbconnect_events) Module Disabled Facebook Social Facebook Friends Invite (fbconnect_invite) Module Not installed 6.x-2.0-beta1
But wait, that's not all, it slices [out your sql queries for text usage]
drush sql-query "select * from users;" > userlist.txt
It dices out those bad seeds [of code that give you a white screen of death and thus prevent you from disabling via the admin interface]
drush dis that_custom_module_with_mo_code_mo_probs
But wait! It juliennes [those files and dbs and sends them to prod] too!
drush rsync demosite.drupal6.local @peerdrush sql-sync demosite.drupal6.local @peer
And oh my, I just learned it can work on remote sites using aliases such as the above
so we can turn
drush username@myserver.com/path/to/drupal#mysite.com status
into
drush @dev status
Drush (as seen on Drupal.org), it's better than sliced bread. Get yours today!
So there you have it folks, contrary to what Druplicon will tell you, Drush is actually better than sliced bread. Check out more cool drush commands here.
Thanks for sharing part of your Friday evening with me and I hope to see you at DrupalCon next week.
Tags: Drupal Planet