(values option-type base arg))
(values :arg arg nil))))
-
+
+(defun find-option (name options)
+ "Find an option in option list. Handles using unique abbreviations"
+ (let* ((option-names (mapcar #'car options))
+ (pos (match-unique-abbreviation name option-names)))
+ (when pos
+ (nth pos options))))
+
(defun match-option (arg options)
"Matches an argument to an option. Returns option-list,option-type,base-name,argument"
(multiple-value-bind (option-type base-name argument) (analyze-arg arg)
- (let ((match (find base-name options :key #'car :test #'equal)))
- (values match option-type base-name argument))))
+ (let ((match (find-option base-name options)))
+ (values match option-type (when match (car match)) argument))))
(defun getopt (args options)
"Processes a list of arguments and options. Returns filtered argument
(push (cons base-name (second pos)) out-opts)
(setq pos (cdr pos))))))))
(t
- (push arg out-args)))))))))
+ (if (in option-type :long :short)
+ (push (nth-value 0 (arg->base-name arg option-type)) errors)
+ (push arg out-args))))))))))