X-Git-Url: https://code.consxy.com/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Frun.lisp;h=311d965366f6049c3a4a061259d6f391f834e75a;hb=88b07c40f1176869b4ed1b7188724c64753ee607;hp=fa9edbe45600258e7c5fd51b87cb9ec552a2984d;hpb=59e9f7983efcc1ee08609b075ea8345e5318b125;p=candle diff --git a/src/main/run.lisp b/src/main/run.lisp index fa9edbe..311d965 100644 --- a/src/main/run.lisp +++ b/src/main/run.lisp @@ -1,3 +1,4 @@ +; Copyright 2022 Frank Duncan (frank@consxy.com) under AGPL3. See distributed LICENSE.txt. (in-package #:candle) (defun import-package (pkg) @@ -5,11 +6,45 @@ (defun run-task (task) (format t "~%~c[1;33mRunning ~:(~A~)~c[0m~%" #\Esc (getf task :name) #\Esc) - (eval (getf task :directions)) -; (format t "~c[1;31mFailed doc check!~c[0m~%" #\Esc #\Esc) - (format t "~c[1;32m- ~:(~A~) Passed!~c[0m~%" #\Esc (getf task :name) #\Esc)) + (if + (eval (getf task :directions)) + (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 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. -(defun run () + If SPECIFIED-TASK exists, only that task is run." (if (not (probe-file ".candle")) :dot-candle-absent @@ -19,4 +54,8 @@ (let ((candle-definition (read str))) (format t "Running tasks for ~(~A~)~%" (getf candle-definition :name)) - (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))))))))