Index: imagecachetest.drush.inc
===================================================================
--- imagecachetest.drush.inc	(revision 0)
+++ imagecachetest.drush.inc	(revision 0)
@@ -0,0 +1,56 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_drush_command().
+ */
+function imagecache_drush_command() {
+  $items = array();
+
+  $items['imagecache-flush'] = array(
+    'callback' => 'imagecache_drush_preset_flush',
+    'description' => dt('Flush an imagecache preset.'),
+    'examples' => array(
+      'drush imagecache flush foobar' => dt('Flush the ImageCache preset "foobar".'),
+    ),
+    'aliases' => array('icf'),
+  );
+
+  return $items;
+}
+
+/**
+ * Implementation of hook_drush_help().
+ */
+function imagecache_drush_help($section) {
+  switch ($section) {
+    case 'drush:imagecache-flush':
+      return dt('Flush a given preset.');
+  }
+}
+
+/**
+ * Drush callback to perform actual imagecache preset flush.
+ */
+function imagecache_drush_preset_flush() {
+  $args = func_get_args();
+  if (empty($args)) {
+    drush_set_error(dt('You must specify a preset name to flush.'));
+  }
+  else {
+    foreach ($args as $arg) {
+      // Load preset.
+      if ($preset = imagecache_preset($arg)) {
+        // This mimics the logic inside of the function
+        // imagecache_preset_flush(), but without the access check.
+        $presetdir = DRUPAL_ROOT . base_path() . file_directory_path() .'/imagecache/'. $preset['presetname'];
+        if (is_dir($presetdir)) {
+          _imagecache_recursive_delete($presetdir);
+          drush_log(dt('Flushed "@preset" preset.', array('@preset' => $arg)), 'ok');
+        }
+        else {
+          drush_log(dt('Cache for preset "@preset" was already empty.', array('@preset' => $arg)), 'ok');
+        }
+      }
+      else {
+        drush_log(dt('Preset "@preset" not found.', array('@preset' => $arg)), 'error');
+      }
+    }
+  }
+  return TRUE;
+}
+

Property changes on: imagecachetest.drush.inc
___________________________________________________________________
Added: svn:keywords
   + Id

