Satisfy style checker
authorFrank Duncan <frank@kank.net>
Sat, 18 Dec 2021 21:00:55 +0000 (15:00 -0600)
committerFrank Duncan <frank@kank.net>
Sat, 18 Dec 2021 21:00:55 +0000 (15:00 -0600)
src/main/aws/aws.lisp
src/main/cli.lisp
src/main/server-cli.lisp
src/main/server.lisp

index 4182c6728fa130063bcc47ab024befc4ce152345..ad224af7439ad7b56ba4ba2a0e17f0cc79fc6935 100644 (file)
 
 (defun aws-command (cmd &rest args)
  (with-output-to-string (out)
 
 (defun aws-command (cmd &rest args)
  (with-output-to-string (out)
- (sb-ext:run-program
-  *aws-exec*
-  (append
-   (list "ec2" cmd)
-   args)
-  :output out
-  :error *error-output*)))
 (sb-ext:run-program
+   *aws-exec*
+   (append
+    (list "ec2" cmd)
+    args)
+   :output out
+   :error *error-output*)))
 
 (defun describe-property (property)
  (read-from-string
 
 (defun describe-property (property)
  (read-from-string
  (let*
   ((out nil)
    (code nil))
  (let*
   ((out nil)
    (code nil))
-   (setf out
-    (with-output-to-string (out-str)
-     (setf code
-      (sb-ext:process-exit-code
-       (sb-ext:run-program
-        *ssh-exec*
-        (list
-         "-o"
-         "StrictHostKeyChecking=no"
-         "-o"
-         "UserKnownHostsFile=/dev/null"
-         "-i"
-         *aws-keyfile*
-         (describe-property "PublicIpAddress")
-         (format nil "cd ~A ; ~A run" *remote-work-dir* *remote-candle-location*))
-        :output out-str
-        :error out-str
-        :wait t)))))
-   (values (zerop code) out)))
+  (setf out
+   (with-output-to-string (out-str)
+    (setf code
+     (sb-ext:process-exit-code
+      (sb-ext:run-program
+       *ssh-exec*
+       (list
+        "-o"
+        "StrictHostKeyChecking=no"
+        "-o"
+        "UserKnownHostsFile=/dev/null"
+        "-i"
+        *aws-keyfile*
+        (describe-property "PublicIpAddress")
+        (format nil "cd ~A ; ~A run" *remote-work-dir* *remote-candle-location*))
+       :output out-str
+       :error out-str
+       :wait t)))))
+  (values (zerop code) out)))
index bacd1e3d62c7d15a6ede410728b02b0e84fb24a9..1fff398fd28aabb595e8c495be6e78e5ba71c58d 100644 (file)
    (:in-progress "In progress"))))
 
 (defmacro standard-cli (cmd options-in args usage remaining-args-required &rest success)
    (:in-progress "In progress"))))
 
 (defmacro standard-cli (cmd options-in args usage remaining-args-required &rest success)
-`(multiple-value-bind (parsed-options remaining-args error) (opera:process-arguments ,options-in ,args)
-  (cond
-   ((opera:option-present :help parsed-options)
-    (format t "~A" ,(if (eql usage :default) `(opera:usage ,cmd ,options-in) usage)))
-   ((eql error :unknown-option)
-    (error-and-exit "Unknown option: ~A.  See '~A --help'.~%" (car remaining-args) ,cmd))
-   ((eql error :required-argument-missing)
-    (error-and-exit "Missing argument for ~A.  See '~A --help'.~%" (car remaining-args) ,cmd))
-   ((and ,remaining-args-required (not remaining-args))
-    (error-and-exit "~A required.  See 'candle --help'.~%" ,remaining-args-required))
-   (t
-    ,@success))))
+ `(multiple-value-bind (parsed-options remaining-args error) (opera:process-arguments ,options-in ,args)
+   (cond
+    ((opera:option-present :help parsed-options)
+     (format t "~A" ,(if (eql usage :default) `(opera:usage ,cmd ,options-in) usage)))
+    ((eql error :unknown-option)
+     (error-and-exit "Unknown option: ~A.  See '~A --help'.~%" (car remaining-args) ,cmd))
+    ((eql error :required-argument-missing)
+     (error-and-exit "Missing argument for ~A.  See '~A --help'.~%" (car remaining-args) ,cmd))
+    ((and ,remaining-args-required (not remaining-args))
+     (error-and-exit "~A required.  See 'candle --help'.~%" ,remaining-args-required))
+    (t
+     ,@success))))
 
 ;;; Section for ./candle
 
 
 ;;; Section for ./candle
 
@@ -42,7 +42,9 @@
  (standard-cli "candle" (main-options) (cdr sb-ext:*posix-argv*) (main-usage) "Command"
   (handler-case
    (if
  (standard-cli "candle" (main-options) (cdr sb-ext:*posix-argv*) (main-usage) "Command"
   (handler-case
    (if
-    (and (opera:option-present :port parsed-options) (not (parse-integer (opera:option-argument :port parsed-options) :junk-allowed t)))
+    (and
+     (opera:option-present :port parsed-options)
+     (not (parse-integer (opera:option-argument :port parsed-options) :junk-allowed t)))
     (error-and-exit "--port requires a number.  See 'candle -h'~%")
     (let
      ((communication:*query-port*
     (error-and-exit "--port requires a number.  See 'candle -h'~%")
     (let
      ((communication:*query-port*
 (defun add-project (args)
  (let
   ((options
 (defun add-project (args)
  (let
   ((options
-   '((:name :help :short "h" :long "help" :description "Print this usage.")
-     (:positional "<name>:<src>" :description "<name> is the name of the project, which must be alphanumeric (hyphens are allowed), while <src> is the location of the repository for cloning.  This location must be accessible by the machine running candle."))))
+    `((:name :help :short "h" :long "help" :description "Print this usage.")
+      (:positional "<name>:<src>"
+       :description
+       ,(format nil "~{~A~}"
+         (list
+          "<name> is the name of the project, which must be alphanumeric (hyphens are allowed), while <src> is the "
+          "location of the repository for cloning.  This location must be accessible by the machine running candle."
+          ""))))))
   (standard-cli "candle project add" options args :default "<name>:<src>"
    (let*
     ((project-definition (car remaining-args))
      (pos (position #\: project-definition)))
     (cond
   (standard-cli "candle project add" options args :default "<name>:<src>"
    (let*
     ((project-definition (car remaining-args))
      (pos (position #\: project-definition)))
     (cond
-     ((not pos) (error-and-exit "Project definition ~A is not valid.  See 'candle project add --help'.~%" project-definition))
+     ((not pos)
+      (error-and-exit "Project definition ~A is not valid.  See 'candle project add --help'.~%" project-definition))
      (t
       (let*
        ((name (subseq project-definition 0 pos))
      (t
       (let*
        ((name (subseq project-definition 0 pos))
 (defun delete-project (args)
  (let
   ((options
 (defun delete-project (args)
  (let
   ((options
-   '((:name :help :short "h" :long "help" :description "Print this usage.")
-     (:positional "<name>" :description "<name> is the name of the project to delete"))))
+    '((:name :help :short "h" :long "help" :description "Print this usage.")
+      (:positional "<name>" :description "<name> is the name of the project to delete"))))
   (standard-cli "candle project delete" options args :default "<name>"
   (standard-cli "candle project delete" options args :default "<name>"
-    (communication:query `(candle:delete-project ,(car remaining-args)))
-    (format t "Removed project ~A~%" (car remaining-args)))))
+   (communication:query `(candle:delete-project ,(car remaining-args)))
+   (format t "Removed project ~A~%" (car remaining-args)))))
 
 (defun show-project (args)
  (let
   ((options
 
 (defun show-project (args)
  (let
   ((options
-   '((:name :help :short "h" :long "help" :description "Print this usage.")
-     (:positional "<name>" :description "<name> is the name of the project to show"))))
+    '((:name :help :short "h" :long "help" :description "Print this usage.")
+      (:positional "<name>" :description "<name> is the name of the project to show"))))
   (standard-cli "candle project show" options args :default "<name>"
    (let*
     ((branch-infos (communication:query `(candle:project-branch-information ,(car remaining-args))))
   (standard-cli "candle project show" options args :default "<name>"
    (let*
     ((branch-infos (communication:query `(candle:project-branch-information ,(car remaining-args))))
 (defun refresh-project (args)
  (let
   ((options
 (defun refresh-project (args)
  (let
   ((options
-   '((:name :help :short "h" :long "help" :description "Print this usage.")
-     (:positional "<name>" :description "<name> is the name of the project to refresh"))))
+    '((:name :help :short "h" :long "help" :description "Print this usage.")
+      (:positional "<name>" :description "<name> is the name of the project to refresh"))))
   (standard-cli "candle project refresh" options args :default "<name>"
    (communication:query `(candle:refresh-project ,(car remaining-args)))
    (format t "Refreshed project ~A~%" (car remaining-args)))))
   (standard-cli "candle project refresh" options args :default "<name>"
    (communication:query `(candle:refresh-project ,(car remaining-args)))
    (format t "Refreshed project ~A~%" (car remaining-args)))))
 (defun project-failures (args)
  (let
   ((options
 (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"))))
+    '((: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"))))
   (standard-cli "candle project failures" options args :default nil
    (format t "~A"
     (communication:query
   (standard-cli "candle project failures" options args :default nil
    (format t "~A"
     (communication:query
-     `(candle:failures ,(when (opera:option-present :project parsed-options) (opera:option-argument :project parsed-options))))))))
+     `(candle:failures
+       ,(when (opera:option-present :project parsed-options)
+         (opera:option-argument :project parsed-options))))))))
 
 ;;; Section for ./candle job
 
 
 ;;; Section for ./candle job
 
 (defun job-list (args)
  (let
   ((options
 (defun job-list (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 jobs to project named by PROJECT"))))
+    '((:name :help :short "h" :long "help" :description "Print this usage.")
+      (:name :project :long "project" :variable-name "PROJECT" :takes-argument t
+       :description "Restrict jobs to project named by PROJECT"))))
   (standard-cli "candle job list" options args :default nil
    (format t "~{~A~%~}"
     (mapcar
      #'job-info->line
   (standard-cli "candle job list" options args :default nil
    (format t "~{~A~%~}"
     (mapcar
      #'job-info->line
-     (sort (communication:query `(candle:project-job-information ,(opera:option-argument :project parsed-options))) #'< :key #'fourth))))))
+     (sort
+      (communication:query `(candle:project-job-information ,(opera:option-argument :project parsed-options)))
+      #'< :key #'fourth))))))
 
 (defun decompose-job-definition (job-definition)
  (let
 
 (defun decompose-job-definition (job-definition)
  (let
 (defun job-log (args)
  (let
   ((options
 (defun job-log (args)
  (let
   ((options
-   '((:name :help :short "h" :long "help" :description "Print this usage.")
-     (:positional "<project>:<sha>" :description "<project> is the name of the project, while <sha> is the sha of the job in question."))))
+    '((:name :help :short "h" :long "help" :description "Print this usage.")
+      (:positional "<project>:<sha>"
+       :description "<project> is the name of the project, while <sha> is the sha of the job in question."))))
   (standard-cli "candle job log" options args :default "<project>:<sha>"
    (multiple-value-bind (project-name sha) (decompose-job-definition (car remaining-args))
     (if project-name
   (standard-cli "candle job log" options args :default "<project>:<sha>"
    (multiple-value-bind (project-name sha) (decompose-job-definition (car remaining-args))
     (if project-name
 (defun retry-job (args)
  (let
   ((options
 (defun retry-job (args)
  (let
   ((options
-   '((:name :help :short "h" :long "help" :description "Print this usage.")
-     (:positional "<project>:<sha>" :description "<project> is the name of the project, while <sha> is the sha of the job in question."))))
+    '((:name :help :short "h" :long "help" :description "Print this usage.")
+      (:positional "<project>:<sha>"
+       :description "<project> is the name of the project, while <sha> is the sha of the job in question."))))
   (standard-cli "candle job retry" options args :default "<project>:<sha>"
    (multiple-value-bind (project-name sha) (decompose-job-definition (car remaining-args))
     (if project-name
   (standard-cli "candle job retry" options args :default "<project>:<sha>"
    (multiple-value-bind (project-name sha) (decompose-job-definition (car remaining-args))
     (if project-name
index b0c378b875da9e709fc4eebd05032d01ae426596..6a6fd06e88e2337cb37bc329db656aadc8f2f57b 100644 (file)
@@ -23,7 +23,9 @@
    (remaining-args
     (format *error-output* "Don't understand ~A.  See 'candle-server -h'~%" (car remaining-args))
     (sb-ext:exit :code 1))
    (remaining-args
     (format *error-output* "Don't understand ~A.  See 'candle-server -h'~%" (car remaining-args))
     (sb-ext:exit :code 1))
-   ((and (opera:option-present :port options) (not (parse-integer (opera:option-argument :port options) :junk-allowed t)))
+   ((and
+     (opera:option-present :port options)
+     (not (parse-integer (opera:option-argument :port options) :junk-allowed t)))
     (format *error-output* "--port requires a number.  See 'candle-server -h'~%"))
    (t
     (let
     (format *error-output* "--port requires a number.  See 'candle-server -h'~%"))
    (t
     (let
                  (opera:option-present :port options)
                  (parse-integer (opera:option-argument :port options) :junk-allowed t))
              25004)))
                  (opera:option-present :port options)
                  (parse-integer (opera:option-argument :port options) :junk-allowed t))
              25004)))
-    (setf candle:*job-system*
-     (if (opera:option-present :system options)
-      (intern (string-upcase (opera:option-argument :system options)) :keyword)
-      :local))
-    (let
-     ((*error-output* (make-broadcast-stream)))
-     (case candle:*job-system*
-      (:aws (asdf:load-system :candle-aws))
-      (:local (asdf:load-system :candle-local))))
-    (setf candle:*candle-dir*
-     (if (opera:option-present :dir options)
-      (opera:option-argument :dir options)
-      "/opt/candle/"))
-    (candle:server port nil))))))
+     (setf candle:*job-system*
+      (if (opera:option-present :system options)
+       (intern (string-upcase (opera:option-argument :system options)) :keyword)
+       :local))
+     (let
+      ((*error-output* (make-broadcast-stream)))
+      (case candle:*job-system*
+       (:aws (asdf:load-system :candle-aws))
+       (:local (asdf:load-system :candle-local))))
+     (setf candle:*candle-dir*
+      (if (opera:option-present :dir options)
+       (opera:option-argument :dir options)
+       "/opt/candle/"))
+     (candle:server port nil))))))
index 338516bed5eae32303ce221773db87296cb09b63..3f022f387b4b70aab74f24b4d349f2d40dc9b92c 100644 (file)
@@ -77,7 +77,9 @@
   ((project (find-project-by-name-or-die name))
    (branches (find-branch-by-project project)))
   (git project "fetch" "origin" "--prune")
   ((project (find-project-by-name-or-die name))
    (branches (find-branch-by-project project)))
   (git project "fetch" "origin" "--prune")
-  (multiple-value-bind (success code out err) (git project "branch" "-r" "--format" "%(refname) %(objectname)" "--list" "origin/*")
+  (multiple-value-bind
+   (success code out err)
+   (git project "branch" "-r" "--format" "%(refname) %(objectname)" "--list" "origin/*")
    (declare (ignore code err))
    (when (not success) (raise-candle-error :project-failed-to-get-branches))
    (mapcar (lambda (branch) (set-branch-in-git branch nil)) branches)
    (declare (ignore code err))
    (when (not success) (raise-candle-error :project-failed-to-get-branches))
    (mapcar (lambda (branch) (set-branch-in-git branch nil)) branches)
      (find-if
       (lambda (job-sha)
        (and (<= (length sha) (length job-sha)) (string= sha (subseq job-sha 0 (length sha)))))
      (find-if
       (lambda (job-sha)
        (and (<= (length sha) (length job-sha)) (string= sha (subseq job-sha 0 (length sha)))))
-     (find-job-by-project project)
-     :key #'job-sha))))
+      (find-job-by-project project)
+      :key #'job-sha))))
   (when (not job) (raise-candle-error :job-does-not-exist))
   job))
 
   (when (not job) (raise-candle-error :job-does-not-exist))
   job))