
Author: mhenoch Date: Wed Mar 5 00:39:54 2008 New Revision: 159 Modified: cl-darcs/trunk/cmdline.lisp cl-darcs/trunk/getopt.lisp Log: Move INVALID-ARGUMENTS condition to getopt.lisp, and use it. Modified: cl-darcs/trunk/cmdline.lisp ============================================================================== --- cl-darcs/trunk/cmdline.lisp (original) +++ cl-darcs/trunk/cmdline.lisp Wed Mar 5 00:39:54 2008 @@ -27,9 +27,6 @@ "Turn a command symbol into a function symbol." (intern (format nil "CMD-~A" command) :darcs))) -(define-condition invalid-arguments (simple-error) - ()) - (defun handle-command-line (argv) "Handle a command line, emulating the real darcs client. ARGV is a list of strings. This function is to be called in some Modified: cl-darcs/trunk/getopt.lisp ============================================================================== --- cl-darcs/trunk/getopt.lisp (original) +++ cl-darcs/trunk/getopt.lisp Wed Mar 5 00:39:54 2008 @@ -16,6 +16,9 @@ (in-package :darcs) +(define-condition invalid-arguments (simple-error) + ()) + ;; The option struct describes a command line option. (defstruct option ;; keyword for return value of GETOPT @@ -53,7 +56,9 @@ (push (cons (option-keyword opt) (if (option-arg opt) (if (or no-argument (null args)) - (error "Option ~A requires an argument." arg) + (error 'invalid-arguments + :format-control "Option ~A requires an argument." + :format-arguments (list arg)) (pop args)) t)) parsed)) @@ -80,7 +85,9 @@ (long-option (maybe-split-long-option arg)) (option (find long-option options :key #'option-long :test #'string=))) (unless option - (error "Unknown long option ~S (none of ~{~S ~})." arg (mapcar #'option-long options))) + (error 'invalid-arguments + :format-control "Unknown long option ~S (none of ~{~S ~})." + :format-arguments (list arg (mapcar #'option-long options)))) (maybe-get-argument arg option))) (:short @@ -93,7 +100,9 @@ (let* ((letter (pop letters)) (option (find letter options :key #'option-short))) (unless option - (error "Unknown option ~A." letter)) + (error 'invalid-arguments + :format-control "Unknown option ~A." + :format-arguments (list letter))) ;; Only the last short option can have an argument. (maybe-get-argument letter option :no-argument (not (null letters)))))))