Improve the CLI situation a bit.

Fix bugs related to parsing the new COPY type, and make it so that we
know how to parse options (and fields, and other type dependant things)
even when --type is missing, in care the source URL has the information.
This commit is contained in:
Dimitri Fontaine 2015-01-06 00:07:31 +01:00
parent e1bc6425e2
commit a86369a03d
3 changed files with 7 additions and 2 deletions

View File

@ -286,6 +286,7 @@
(source (if type
(parse-source-string-for-type type source)
(parse-source-string source)))
(type (parse-cli-type (conn-type source)))
(target (parse-target-string (second arguments))))
;; some verbosity about the parsing "magic"

View File

@ -476,6 +476,7 @@
;; connection types / classes symbols for use in main
#:connection
#:conn-type
#:csv-connection
#:fixed-connection
#:copy-connection

View File

@ -258,6 +258,7 @@
(defrule cli-type (or "csv"
"fixed"
"copy"
dbf-type-name
"ixf"
"sqlite"
@ -281,16 +282,18 @@
(loop :for field :in fields
:append (parse (case type
(:csv 'csv-source-fields)
(:fixed 'fixed-source-fields))
(:fixed 'fixed-source-fields)
(:copy 'copy-source-fields))
field)))
(defun parse-cli-options (type options)
"Parse options as per the WITH clause when we get them from the CLI."
(alexandria:alist-plist
(loop :for option :in options
:collect (parse (case type
:collect (parse (ecase type
(:csv 'csv-option)
(:fixed 'fixed-option)
(:copy 'copy-option)
(:dbf 'dbf-option)
(:ixf 'ixf-option)
(:sqlite 'sqlite-option)