Error out when using ignored options.

In the theory that it's a better service to the user to refuse doing
anything at all rather than ignore his/her commands, print out FATAL
errors when options are used that are incompatible with a load command
file.

See #327 for a case where this did happen.

In passing, tweak our report code to avoid printing the footer when we
didn't print anything at all previously.
This commit is contained in:
Dimitri Fontaine 2016-01-25 11:46:36 +01:00
parent 4e36bd3c55
commit 64ab4d28dc
2 changed files with 23 additions and 3 deletions

View File

@ -324,7 +324,26 @@
before after))
(t
;; process the files
(mapcar #'process-command-file arguments))))
;; other options are not going to be used here
(let ((cli-options `(("--type" ,type)
("--encoding" ,encoding)
("--set" ,set)
("--with" ,with)
("--field" ,field)
("--cast" ,cast)
("--before" ,before)
("--after" ,after))))
(loop :for (cli-option-name cli-option-value)
:in cli-options
:when cli-option-value
:do (log-message
:fatal
"Option ~s is ignored when using a load file"
cli-option-name))
;; when we issued a single error previously, do nothing
(unless (remove-if #'null (mapcar #'second cli-options))
(mapcar #'process-command-file arguments))))))
(source-definition-error (c)
(log-message :fatal "~a" c)

View File

@ -133,8 +133,9 @@
(when (and ws (not (= ws 0.0))) (format-interval ws nil)))))
(defun report-pgstate-stats (pgstate legend)
(with-slots (read rows errs secs rs ws) pgstate
(report-footer legend read rows errs secs rs ws)))
(with-slots (tabnames read rows errs secs rs ws) pgstate
(when tabnames
(report-footer legend read rows errs secs rs ws))))
;;;
;;; Pretty print the whole summary from a state