;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
(defpackage #:zone.frontend
- (:use #:common-lisp #:optparse #:net #:zone
- #+cmu #:mop
+ (:use #:common-lisp #:mdw.sys-base #:optparse #:net #:zone
+ #+(or cmu clisp) #:mop
#+sbcl #:sb-mop)
(:export #:main))
(in-package #:zone.frontend)
"Which zones to be emitted.")
(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
+ (make-pathname :directory
(append (or (pathname-directory path)
(list :relative))
(list (pathname-name path)))
(#\s "subnet" (:arg "NET")
(list zone:*preferred-subnets*)
"Designate NET as a preferred subnet.")
+ (#\D "debug" (set opt-debug)
+ "Produce stack backtrace on error.")
"Output options"
(#\d "directory" (:arg "DIRECTORY")
(dir *zone-output-path*)
"Write information about zone NAME.")))
(defun main ()
- (with-unix-error-reporting ()
- (let ((files nil))
- (unless (option-parse-try
- (do-options ()
- (nil (rest)
- (when (zerop (length rest))
- (option-parse-error "no files to read"))
- (setf files rest))))
- (die-usage))
- (dolist (f files)
- (let ((*package* (make-package "ZONE.SCRATCH"
- :use '(#:common-lisp #:net #:zone))))
- (load f :verbose nil :print nil :if-does-not-exist :error)
- (delete-package *package*)))
- (zone-save opt-zones :format opt-format))))
+ (set-command-line-arguments)
+ (let ((files nil))
+ (flet ((run ()
+ (dolist (f files)
+ (let ((*package* (make-package "ZONE.SCRATCH"
+ :use '(#:common-lisp
+ #:net #:zone))))
+ (load f :verbose nil :print nil :if-does-not-exist :error)
+ (delete-package *package*)))
+ (zone-save opt-zones :format opt-format)))
+ (with-unix-error-reporting ()
+ (unless (option-parse-try
+ (do-options ()
+ (nil (rest)
+ (when (zerop (length rest))
+ (option-parse-error "no files to read"))
+ (setf files rest))))
+ (die-usage)))
+ (if opt-debug
+ (run)
+ (with-unix-error-reporting () (run))))))
;;;----- That's all, folks --------------------------------------------------