+(defvar opt-format :bind
+ "Which format to use on output.")
+(defvar opt-debug nil
+ "Whether to emit stack backtraces on error.")
+
+(defun directory-exists-p (name)
+
+ ;; Make a pathname for NAME which has the right form for a directory.
+ (let ((dirpath
+ (let ((path (pathname name)))
+ (if (null (pathname-name path))
+ path
+ (make-pathname :directory
+ (append (or (pathname-directory path)
+ (list :relative))
+ (list (pathname-name path)))
+ :name nil
+ :type nil
+ :defaults path)))))
+
+ ;; Now check that it exists.
+ #+clisp (and (ext:probe-directory dirpath) (truename dirpath))
+ #-clisp (probe-file dirpath)))
+
+(eval-when (:compile-toplevel :load-toplevel)
+ (defopthandler dir (var arg) ()
+ (let ((path (directory-exists-p arg)))
+ (if (and path
+ (not (pathname-name path)))
+ (setf var path)
+ (option-parse-error "path `~A' doesn't name a directory." arg)))))