Add project failures command
authorFrank Duncan <frank@kank.net>
Wed, 15 Dec 2021 20:17:46 +0000 (14:17 -0600)
committerFrank Duncan <frank@kank.net>
Wed, 15 Dec 2021 20:17:46 +0000 (14:17 -0600)
src/main/cli.lisp
src/main/package.lisp
src/main/server.lisp

index c7a079e64dc718199ccf365729f18574b878eecd..d0a5c2157989c189ca02c4d5de3d67d56bd30783 100644 (file)
@@ -72,6 +72,7 @@
       (:show (show-project (cdr remaining-args)))
       (:refresh (refresh-project (cdr remaining-args)))
       (:list (list-projects))
       (:show (show-project (cdr remaining-args)))
       (:refresh (refresh-project (cdr remaining-args)))
       (:list (list-projects))
+      (:failures (project-failures (cdr remaining-args)))
       (t (project-usage))))))))
 
 (defun project-usage ()
       (t (project-usage))))))))
 
 (defun project-usage ()
 (defun list-projects ()
  (format t "~{~{~A  ~A~}~%~}" (communication:query `(candle:list-projects))))
 
 (defun list-projects ()
  (format t "~{~{~A  ~A~}~%~}" (communication:query `(candle:list-projects))))
 
+(defun project-failures (args)
+ (let*
+  ((options
+   '((:name :help :short "h" :long "help" :description "Print this usage.")
+     (:name :project :long "project" :variable-name "PROJECT" :takes-argument t :description "Restrict failures to project named by PROJECT")))
+    (usage (opera:usage "candle project failures" options)))
+  (multiple-value-bind (options remaining-args error) (opera:process-arguments options args)
+   (cond
+    ((eql error :unknown-option) (format *error-output* "Unknown option: ~A.  See 'candle project failures --help'.~%" (car remaining-args)))
+    ((eql error :required-argument-missing) (format *error-output* "Missing argument for ~A.  See 'candle project failures --help'.~%" (car remaining-args)))
+    ((opera:option-present :help options) (format t "~A" usage))
+    (t
+     (format t "~A"
+      (communication:query
+       `(candle:failures ,(when (opera:option-present :project options) (opera:option-argument :project options))))))))))
+
 ;;; Section for ./candle job
 
 (defmethod execute-command ((command (eql :job)) args)
 ;;; Section for ./candle job
 
 (defmethod execute-command ((command (eql :job)) args)
index 848b09f441ea824d2eced9cc66f70ae5ae6db963..0f565c48ca214909df170fa1f73381c2ecfa87f8 100644 (file)
@@ -1,7 +1,7 @@
 (defpackage #:candle (:use :cl)
  (:export
   #:server #:add-project #:delete-project #:refresh-project #:list-projects
 (defpackage #:candle (:use :cl)
  (:export
   #:server #:add-project #:delete-project #:refresh-project #:list-projects
-  #:project-branch-information #:run #:*candle-dir* #:*job-system* #:*candle-dir*
+  #:project-branch-information #:run #:*candle-dir* #:*job-system* #:*candle-dir* #:failures
   #:project-job-information #:get-job-log #:job-project #:project-dir #:process-job-in-system))
 
 (defpackage #:candle-cli (:use :cl) (:export :run))
   #:project-job-information #:get-job-log #:job-project #:project-dir #:process-job-in-system))
 
 (defpackage #:candle-cli (:use :cl) (:export :run))
index ef80743b6cd9ab45bb5de390f73892a539858845..f95976e3b1a3a066b51381cdfdc7bc3ef5e214ff 100644 (file)
     (project-name project)
     (project-src project)))
   *all-project*))
     (project-name project)
     (project-src project)))
   *all-project*))
+
+(defun failures (project-name)
+ (length
+  (remove-if-not
+   (lambda (branch) (eql :failed (job-status (branch-job branch))))
+   (if project-name
+     (find-branch-by-project
+      (find project-name *all-project* :test #'string= :key #'project-name))
+     *all-branch*))))