From c26278c5104d46b7bb43ccaae96418942bf8d33e Mon Sep 17 00:00:00 2001 From: Dmitry Galinsky Date: Sat, 7 Mar 2009 01:00:51 +0300 Subject: [PATCH] Cleanup the rake and the generator bundles. --- bundles/rails-generator-bundle.el | 68 +++++++++++-------------------- bundles/rails-rake-bundle.el | 41 +++++++------------ 2 files changed, 39 insertions(+), 70 deletions(-) diff --git a/bundles/rails-generator-bundle.el b/bundles/rails-generator-bundle.el index 9148639..b35bab6 100644 --- a/bundles/rails-generator-bundle.el +++ b/bundles/rails-generator-bundle.el @@ -89,56 +89,36 @@ (defun rails/generator-bundle/generate (&optional task) "Run a Generator task." (interactive) - (when-bind (root (rails/root)) - (let (options) - (unless task - (setq task - (rails/completing-read "What generate" - (rails/generator-bundle/list-of-tasks root) - nil - (car rails/generator-bundle/history) - 'rails/generator-bundle/history))) - (unless (string-ext/empty-p task) - (setq options (read-string (format "Name and/or options for [%s]: " task))) - (unless (string-ext/empty-p options) - (rails/generator-bundle/run root - "generate" - task - options - rails/generator-bundle/options)))))) + (rails/with-root nil + (if task + (let (options) + (unless (string-ext/empty-p task) + (setq options (read-string (format "Name and/or options for [%s]: " task))) + (unless (string-ext/empty-p options) + (rails/generator-bundle/run (rails/root) + "generate" + task + options + rails/generator-bundle/options)))) + (rails/anything/run-with-pattern "gen ")))) (defun rails/generator-bundle/destroy (&optional task) "Run a Destroy task." (interactive) - (when-bind (root (rails/root)) - (let (options) - (unless task - (setq task - (rails/completing-read "What destroy" - (rails/generator-bundle/list-of-tasks root) - nil - (car rails/generator-bundle/history) - 'rails/generator-bundle/history))) - (unless (string-ext/empty-p task) - (setq options (read-string (format "Name of [%s]: " task))) - (unless (string-ext/empty-p options) - (rails/generator-bundle/run root "destroy" task options)))))) + (rails/with-root nil + (if task + (let (options) + (unless (string-ext/empty-p task) + (setq options (read-string (format "Name of [%s]: " task))) + (unless (string-ext/empty-p options) + (rails/generator-bundle/run (rails/root) "destroy" task options)))) + (rails/anything/run-with-pattern "des ")))) (defun rails/generator-bundle/reset-cache () (interactive) (when-bind (root (rails/root)) (rails/generator-bundle/create-cache root))) -(defun rails/generator-bundle/gen () - (interactive) - (when-bind (root (rails/root)) - (rails/anything/run-with-pattern "gen "))) - -(defun rails/generator-bundle/des () - (interactive) - (when-bind (root (rails/root)) - (rails/anything/run-with-pattern "des "))) - ;;; --------------------------------------------------------- ;;; - Bundle ;;; @@ -146,11 +126,11 @@ (rails/defbundle "Generator" (:menu (([reset] (cons "Reset Cache" 'rails/generator-bundle/reset-cache)) - ([destroy] (cons "Destroy" 'rails/generator-bundle/des)) - ([create] (cons "Generate" 'rails/generator-bundle/gen))) + ([destroy] (cons "Destroy" 'rails/generator-bundle/destroy)) + ([create] (cons "Generate" 'rails/generator-bundle/generate))) :keys - (("e" 'rails/generator-bundle/gen) - ("E" 'rails/generator-bundle/des)) + (("e" 'rails/generator-bundle/generate) + ("E" 'rails/generator-bundle/destroy)) :triggers (("gen" "Generate" (candidates diff --git a/bundles/rails-rake-bundle.el b/bundles/rails-rake-bundle.el index bdb04e4..7bb781b 100644 --- a/bundles/rails-rake-bundle.el +++ b/bundles/rails-rake-bundle.el @@ -142,43 +142,32 @@ (defun rails/rake-bundle/run (&optional task) "Run a Rake task." (interactive) - (when-bind (root (rails/root)) - (let ((task (if task - task - (rails/completing-read "What task run" - (rails/rake-bundle/list-of-tasks root) - nil - (car rails/rake-bundle/history) - 'rails/rake-bundle/history)))) - (when (not (string-ext/empty-p task)) - (rails/rake-bundle/task-run root task))))) + (rails/with-root nil + (if task + (when (not (string-ext/empty-p task)) + (rails/rake-bundle/task-run root task)) + (rails/rake-bundle/list-tasks)))) (defun rails/rake-bundle/run-with-args (&optional task) "Run a Rake task with arguments ARGS." (interactive) - (when-bind (root (rails/root)) - (let ((task (if task - task - (rails/completing-read "What task run" - (rails/rake-bundle/list-of-tasks root) - nil - (car rails/rake-bundle/history) - 'rails/rake-bundle/history))) - args) - (when (not (string-ext/empty-p task)) - (setq args (read-string (format "Arguments fo %s: " task))) - (rails/rake-bundle/task-run root task args))))) + (rails/with-root nil + (if task + (when (not (string-ext/empty-p task)) + (let ((args (read-string (format "Arguments fo %s: " task)))) + (rails/rake-bundle/task-run root task args))) + (rails/rake-bundle/list-tasks)))) (defun rails/rake-bundle/reset-cache () "Reset tasks cache." (interactive) - (when-bind (root (rails/root)) - (rails/rake-bundle/create-tasks-cache root))) + (rails/with-root nil + (rails/rake-bundle/create-tasks-cache (rails/root)))) (defun rails/rake-bundle/list-tasks () "List of availabled Rake tasks." (interactive) - (when-bind (root (rails/root)) + (rails/with-root nil (rails/anything/run-with-pattern "rake "))) ;;; --------------------------------------------------------- @@ -190,7 +179,7 @@ (([reset] (cons "Reset Tasks Cache" 'rails/rake-bundle/reset-cache)) ([task] (cons "Run Rake Task" 'rails/rake-bundle/list-tasks))) :keys - (("r" 'rails/rake-bundle/anything)) + (("r" 'rails/rake-bundle/list-tasks)) :triggers (("rake" "Rake Task" (candidates