Commit 46c0a3b1 authored by Francois-Rene Rideau's avatar Francois-Rene Rideau

tools: export the success / failure infrastructure.

parent 68d2fa4b
......@@ -136,3 +136,12 @@
(when (failurep (multiple-value-list (with-failure-context () (funcall thunk))))
(setf failurep t)))
(failure-if failurep (make-failures)))))
(defun run-command (fun &rest args)
(let ((results (multiple-value-list (with-failure-context () (apply fun (rest args))))))
;; Don't print anything on success for regular commands, otherwise print all values returned.
(if (failurep results)
(let ((failures (failure-failures results)))
(format t "~&Failure~P:~{~& ~A~}~&" (length failures) failures))
(format t "~{~&~S~&~}" (if (successp results) (success-values results) results)))
(apply 'values results)))
......@@ -96,13 +96,7 @@ based on a list of targets"
;;; NB: For access control, you could check that only exported symbols are used as entry points.
(defun process-arguments (args)
(if-let ((fun (and args (find-command (first args)))))
(let ((results (multiple-value-list (with-failure-context () (apply fun (rest args))))))
;; Don't print anything on success for regular commands, otherwise print all values returned.
(if (failurep results)
(let ((failures (failure-failures results)))
(format t "~&Failure~P:~{~& ~A~}~&" (length failures) failures))
(format t "~{~&~S~&~}" (if (successp results) (success-values results) results)))
(apply 'values results))
(run-command fun (rest args))
(progn
(if args
(format t "Command ~A not found~%" (first args))
......
(defpackage :asdf-tools
(:use :common-lisp :uiop :asdf
:fare-utils :inferior-shell :lisp-invocation :cl-ppcre :optima :optima.ppcre)
(:export)) ;; TODO: export stuff
(:export ;; TODO: export stuff
;; failure
#:with-failure-context #:success #:failure #:success-if #:failure-if #:fail!
#:without-stopping #:call-without-stopping #:run-command))
;; Just so we can use the name in our test scripts...
(defpackage :asdf-test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment