Add specifying task to candle run
[candle] / src / main / cli.lisp
index 1fff398fd28aabb595e8c495be6e78e5ba71c58d..75ecd40b3af6b6c15eb5fe7527e1abd7d80b36f4 100644 (file)
 
 (defmethod execute-command ((command (eql :run)) args)
  (let
-  ((options '((:name :help :short "h" :long "help" :description "Print this usage."))))
-  (standard-cli "run" options args :default nil
-   (when (not (candle:run)) (sb-ext:exit :code 1)))))
+  ((options
+    '((:name :help :short "h" :long "help" :description "Print this usage.")
+      (:name :task :long "task" :variable-name "TASK" :takes-argument t :description "Run TASK"))))
+  (standard-cli "candle run" options args :default nil
+   (cond
+    ((opera:option-present :task parsed-options)
+     (let
+      ((tasks (candle:list-tasks))
+       (specified-task (intern (string-upcase (opera:option-argument :task parsed-options)) :keyword)))
+      (if
+       (not (find specified-task (candle:list-tasks)))
+       (error-and-exit "Task ~(~A~) does not exist in .candle file" specified-task)
+       (candle:run specified-task))))
+    (t (when (not (candle:run)) (sb-ext:exit :code 1)))))))