1 ; Copyright 2022 Frank Duncan (frank@consxy.com) under AGPL3. See distributed LICENSE.txt.
4 (defun import-package (pkg)
5 (asdf:load-system pkg))
8 (format t "~%~c[1;33mRunning ~:(~A~)~c[0m~%" #\Esc (getf task :name) #\Esc)
10 (eval (getf task :directions))
11 (progn (format t "~c[1;32m- ~:(~A~) Passed!~c[0m~%" #\Esc (getf task :name) #\Esc) t)
12 (format t "~c[1;31m- ~:(~A~) Failed!~c[0m~%" #\Esc (getf task :name) #\Esc)))
21 TASK: a keyword, representing a task that can be run
25 Get a list of tasks available in the current .candle file."
27 (not (probe-file ".candle"))
29 (with-open-file (str ".candle")
30 (asdf:initialize-source-registry `(:source-registry (:tree ,(car (directory "."))) :INHERIT-CONFIGURATION))
31 (mapcar #'import-package (cdr (read str)))
32 (mapcar (lambda (task) (getf task :name)) (getf (read str) :tasks)))))
34 (defun run (&optional specified-task)
35 "RUN &optional SPECIFIED-TASK => RESULT
39 SPECIFIED-TASK: a keyword, the task to run
40 RESULT: a boolean, whether the process was successful
44 Runs the script specified by the .candle file in the current directory.
45 When completed, the boolean will be returned if it was successful or not.
47 If SPECIFIED-TASK exists, only that task is run."
49 (not (probe-file ".candle"))
51 (with-open-file (str ".candle")
52 (asdf:initialize-source-registry `(:source-registry (:tree ,(car (directory "."))) :INHERIT-CONFIGURATION))
53 (mapcar #'import-package (cdr (read str)))
55 ((candle-definition (read str)))
56 (format t "Running tasks for ~(~A~)~%" (getf candle-definition :name))
60 (lambda (task) (and specified-task (not (eql (getf task :name) specified-task))))
61 (getf candle-definition :tasks))))))))