Cleaned up the code. added some documentation.
This commit is contained in:
+11
-12
@@ -51,24 +51,26 @@
|
||||
args)
|
||||
|
||||
|
||||
;; goal: Process the standard result of a Git command.
|
||||
;; pre: exit-code and out belong to the completed Git command.
|
||||
;; post: Successful output has been displayed or a Git exception has been raised.
|
||||
;; result: #t when exit-code is zero.
|
||||
(define (std-process-git-result cmd exit-code result output out info)
|
||||
(if (= exit-code 0)
|
||||
(if result
|
||||
(begin
|
||||
(git-displ out)
|
||||
#t)
|
||||
(git-error cmd "Error" out))
|
||||
(begin
|
||||
(git-displ (map cadr output))
|
||||
#t)
|
||||
(git-error cmd (format "Exitcode <> 0: ~a" exit-code) out)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; goal: Define the internal proxy for a Git command.
|
||||
;; pre: pre-code and process-result accept the command proxy arguments.
|
||||
;; post: The proxy invokes Git without standard input and processes its result.
|
||||
;; result: A procedure named f accepting a list of Git arguments.
|
||||
(define-syntax def-git-cmd-proxy
|
||||
(syntax-rules ()
|
||||
((_ f cmd)
|
||||
(def-proxy-cmd f cmd (λ (args info) args) standard-result))
|
||||
((_ f cmd pre-code)
|
||||
(def-proxy-cmd f cmd pre-code standard-result))
|
||||
((_ f cmd pre-code process-result)
|
||||
(define (f args*)
|
||||
(let* ((args (flatten args*))
|
||||
@@ -79,6 +81,3 @@
|
||||
(process-result cmd exit-code result output out info))))))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user