X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=candle;a=blobdiff_plain;f=src%2Fmain%2Frun.lisp;h=659beed84c22df9145227c5798aa47c05202fa4a;hp=d9797350547fe8403e6f0679435fe6383f644487;hb=5c21748c18e32bb9fe17bb4c23329be02edc23a2;hpb=ec3c4dac8416e025e186501842723852b16cab4e diff --git a/src/main/run.lisp b/src/main/run.lisp index d979735..659beed 100644 --- a/src/main/run.lisp +++ b/src/main/run.lisp @@ -10,17 +10,40 @@ (progn (format t "~c[1;32m- ~:(~A~) Passed!~c[0m~%" #\Esc (getf task :name) #\Esc) t) (format t "~c[1;31m- ~:(~A~) Failed!~c[0m~%" #\Esc (getf task :name) #\Esc))) -(defun run () - "RUN => RESULT +(defun list-tasks () + "LIST-TASKS => TASKS + + TASKS: TASK* ARGUMENTS AND VALUES: + TASK: a keyword, representing a task that can be run + +DESCRIPTION: + + Get a list of tasks available in the current .candle file." + (if + (not (probe-file ".candle")) + :dot-candle-absent + (with-open-file (str ".candle") + (asdf:initialize-source-registry `(:source-registry (:tree ,(car (directory "."))) :INHERIT-CONFIGURATION)) + (mapcar #'import-package (cdr (read str))) + (mapcar (lambda (task) (getf task :name)) (getf (read str) :tasks))))) + +(defun run (&optional specified-task) + "RUN &optional SPECIFIED-TASK => RESULT + +ARGUMENTS AND VALUES: + + SPECIFIED-TASK: a keyword, the task to run RESULT: a boolean, whether the process was successful DESCRIPTION: Runs the script specified by the .candle file in the current directory. - When completed, the boolean will be returned if it was successful or not." + When completed, the boolean will be returned if it was successful or not. + + If SPECIFIED-TASK exists, only that task is run." (if (not (probe-file ".candle")) :dot-candle-absent @@ -30,4 +53,8 @@ DESCRIPTION: (let ((candle-definition (read str))) (format t "Running tasks for ~(~A~)~%" (getf candle-definition :name)) - (every #'identity (mapcar #'run-task (getf candle-definition :tasks))))))) + (every #'identity + (mapcar #'run-task + (remove-if + (lambda (task) (and specified-task (not (eql (getf task :name) specified-task)))) + (getf candle-definition :tasks))))))))