1.1--- a/lisp/lib/cli/clap/util.lisp Sun Sep 08 21:14:30 2024 -0400
1.2+++ b/lisp/lib/cli/clap/util.lisp Tue Sep 10 21:26:30 2024 -0400
1.3@@ -8,11 +8,22 @@
1.4 (defun arg0 () (car sb-ext:*posix-argv*))
1.5 (defun args () (cdr sb-ext:*posix-argv*))
1.6
1.7+(declaim (inline long-opt-p long-opt-has-eq-p
1.8+ short-opt-p opt-group-p
1.9+ opt-string-prefix-eq))
1.10+
1.11 (defun long-opt-p (str)
1.12 (declare (simple-string str))
1.13 (and (char= (aref str 0) (aref str 1) #\-)
1.14 (> (length str) 2)))
1.15
1.16+(defun long-opt-has-eq-p (str)
1.17+ "Return non-nil if STR is a long-opt which has an '=' somewhere,
1.18+indicating a key/val pair without whitespace."
1.19+ (declare (simple-string str))
1.20+ (when-let ((pos (position #\= str :test 'char=)))
1.21+ (cons (subseq str 2 pos) (subseq str (1+ pos)))))
1.22+
1.23 (defun short-opt-p (str)
1.24 (declare (simple-string str))
1.25 (and (char= (aref str 0) #\-)