changelog shortlog graph tags branches changeset file revisions annotate raw help

Mercurial > core / lisp/lib/cli/clap/util.lisp

revision 643: f901de70a80e
parent 426: 3e721a3349a0
child 645: 3e6a17fb5712
     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) #\-)