Index: imagecache.drush.inc
===================================================================
--- imagecache.drush.inc	(revision 0)
+++ imagecache.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".'),
+    ),
+  );
+
+  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 {
+    // Load preset.
+    if ($preset = imagecache_preset($args[0])) {
+      // This mimics the logic inside of the function
+      // imagecache_preset_flush(), but without the access check.
+      $presetdir = realpath(file_directory_path() .'/imagecache/'. $preset['presetname']);
+      if (is_dir($presetdir)) {
+        _imagecache_recursive_delete($presetdir);
+      }
+      drush_print(dt('Flushed "@preset" preset.', array('@preset' => $args[0])));
+    }
+    else {
+      drush_set_error(dt('Preset "@preset" not found.', array('@preset' => $args[0])));
+    }
+  }
+  return TRUE;
+}
+

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

