mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-05 02:46:10 +02:00
Cleanup some code location.
This commit is contained in:
parent
a86369a03d
commit
d9f5bff5e0
@ -349,6 +349,46 @@
|
||||
(log-message :error "Can not find file: ~s" filename)))
|
||||
(format t "~&"))
|
||||
|
||||
(defun run-commands (source
|
||||
&key
|
||||
(start-logger t)
|
||||
((:summary *summary-pathname*) *summary-pathname*)
|
||||
((:log-filename *log-filename*) *log-filename*)
|
||||
((:log-min-messages *log-min-messages*) *log-min-messages*)
|
||||
((:client-min-messages *client-min-messages*) *client-min-messages*))
|
||||
"SOURCE can be a function, which is run, a list, which is compiled as CL
|
||||
code then run, a pathname containing one or more commands that are parsed
|
||||
then run, or a commands string that is then parsed and each command run."
|
||||
|
||||
(with-monitor (:start-logger start-logger)
|
||||
(let* ((funcs
|
||||
(typecase source
|
||||
(function (list source))
|
||||
|
||||
(list (list (compile nil source)))
|
||||
|
||||
(pathname (mapcar (lambda (expr) (compile nil expr))
|
||||
(parse-commands-from-file source)))
|
||||
|
||||
(t (mapcar (lambda (expr) (compile nil expr))
|
||||
(if (probe-file source)
|
||||
(parse-commands-from-file source)
|
||||
(parse-commands source)))))))
|
||||
|
||||
;; maybe duplicate the summary to a file
|
||||
(let* ((summary-stream (when *summary-pathname*
|
||||
(open *summary-pathname*
|
||||
:direction :output
|
||||
:if-exists :rename
|
||||
:if-does-not-exist :create)))
|
||||
(*report-stream* (or summary-stream *standard-output*)))
|
||||
(unwind-protect
|
||||
;; run the commands
|
||||
(loop for func in funcs do (funcall func))
|
||||
|
||||
;; cleanup
|
||||
(when summary-stream (close summary-stream)))))))
|
||||
|
||||
|
||||
;;;
|
||||
;;; Main API to use from outside of pgloader.
|
||||
|
||||
@ -459,7 +459,7 @@
|
||||
(:import-from #:pgloader.db3 #:dbf-connection)
|
||||
(:import-from #:pgloader.ixf #:ixf-connection)
|
||||
(:export #:parse-commands
|
||||
#:run-commands
|
||||
#:parse-commands-from-file
|
||||
|
||||
;; tools to enable complete CLI parsing in main.lisp
|
||||
#:process-relative-pathnames
|
||||
|
||||
@ -132,46 +132,6 @@
|
||||
;; normal error processing happen
|
||||
(parse 'commands content))))))
|
||||
|
||||
(defun run-commands (source
|
||||
&key
|
||||
(start-logger t)
|
||||
((:summary *summary-pathname*) *summary-pathname*)
|
||||
((:log-filename *log-filename*) *log-filename*)
|
||||
((:log-min-messages *log-min-messages*) *log-min-messages*)
|
||||
((:client-min-messages *client-min-messages*) *client-min-messages*))
|
||||
"SOURCE can be a function, which is run, a list, which is compiled as CL
|
||||
code then run, a pathname containing one or more commands that are parsed
|
||||
then run, or a commands string that is then parsed and each command run."
|
||||
|
||||
(with-monitor (:start-logger start-logger)
|
||||
(let* ((funcs
|
||||
(typecase source
|
||||
(function (list source))
|
||||
|
||||
(list (list (compile nil source)))
|
||||
|
||||
(pathname (mapcar (lambda (expr) (compile nil expr))
|
||||
(parse-commands-from-file source)))
|
||||
|
||||
(t (mapcar (lambda (expr) (compile nil expr))
|
||||
(if (probe-file source)
|
||||
(parse-commands-from-file source)
|
||||
(parse-commands source)))))))
|
||||
|
||||
;; maybe duplicate the summary to a file
|
||||
(let* ((summary-stream (when *summary-pathname*
|
||||
(open *summary-pathname*
|
||||
:direction :output
|
||||
:if-exists :rename
|
||||
:if-does-not-exist :create)))
|
||||
(*report-stream* (or summary-stream *standard-output*)))
|
||||
(unwind-protect
|
||||
;; run the commands
|
||||
(loop for func in funcs do (funcall func))
|
||||
|
||||
;; cleanup
|
||||
(when summary-stream (close summary-stream)))))))
|
||||
|
||||
|
||||
;;;
|
||||
;;; Parse an URI without knowing before hand what kind of uri it is.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user