src/frontend.lisp: Make the option parser available in a special variable.
[sod] / src / frontend.lisp
index 7648e2d..d3d9d9d 100644 (file)
@@ -24,7 +24,7 @@
 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 (cl:defpackage #:sod-frontend
-  (:use #:common-lisp #:optparse #:sod #:sod-parser)
+  (:use #:common-lisp #:sod-utilities #:optparse #:sod #:sod-parser)
   (:shadowing-import-from #:optparse #:int))
 
 (cl:in-package #:sod-frontend)
@@ -38,6 +38,9 @@
 ;;;--------------------------------------------------------------------------
 ;;; The main program.
 
+(defvar-unbound *option-parser*
+  "The program's main option parser.")
+
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (defopthandler dirpath (var arg) ()
     "Convert the argument into a pathname with a directory component
                     (list output-reasons 'keyword))))
 
     ;; Actually parse the options.
-    (unless (and (option-parse-try
-                  (do-options ()
-                    (nil (rest)
-                         (setf args rest))))
-                (or builtinsp args))
-      (die-usage))
+    (let ((*option-parser* (make-option-parser)))
+      (unless (and (option-parse-try
+                    (do-options (:parser *option-parser*)
+                      (nil (rest)
+                           (setf args rest))))
+                  (or builtinsp args))
+       (die-usage)))
 
     ;; Do the main parsing job.
     (labels ((hack-module (module)