;;; A tiny example, hacked together in some minutes. ;;; It is not tested, intended just to demonstrate the usage of prase-command-line-options. ;;; Look at the macro-expandings of with-command-line-options and make-argument-list. (defpackage #:command-line-demo (:use #:cl #:parse-command-line-options)) (in-package :command-line-demo) (defun foo-toplevel () ;; catch errors ;; (sb-ext:disable-debugger) (setf sb-ext:*invoke-debugger-hook* #'custom-debugger-disabled-hook) (setf *default-data-path* *default-pathname-defaults*) (handler-case (with-command-line-options (no-info (quiet "--quiet" "-q") (help "--help" "-h" "--usage") ;; options no-progress ;; output foo-output foo-output-format foo-output-if-exists foo-output-if-does-not-exist ) (unless (or no-info-supplied-p quiet-supplied-p) (format *trace-output* "~&~%=============== Foo-Programm ===============~&~%")) (when help-supplied-p (format *trace-output* *help-string*) (quit-foo)) (when foo-output (apply #'make-foo-to-file foo-output (make-argument-list (:show-progress (and (not no-progress-supplied-p) (not quiet-supplied-p))) (:format (read-from-string foo-output-format) foo-output-format-supplied-p) (:if-exists (read-from-string foo-output-if-exists) foo-output-if-exists-supplied-p) (:if-does-not-exist (read-from-string foo-output-if-does-not-exist) foo-output-if-does-not-exist-supplied-p))))) ;; error-clauses (command-line-problem (condition) (handle-command-line-problem condition)) (file-error (condition) (handle-file-error condition))) (quit-foo))