From c06093021aaea7c30f093a7df57cfac615bbcb39 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sun, 4 Aug 2019 18:56:46 +0100 Subject: [PATCH] src/optparse.lisp: Cope with options which don't have long names. Organization: Straylight/Edgeware From: Mark Wooding This makes the format strings remarkably hairy, but that just adds to the fun, right? --- src/optparse.lisp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/optparse.lisp b/src/optparse.lisp index c901a9e..5017fe4 100644 --- a/src/optparse.lisp +++ b/src/optparse.lisp @@ -997,7 +997,8 @@ (defun show-options-help (opts &optional (stream *standard-output*)) (dolist (o opts) (let ((doc (opt-documentation o))) (cond ((not o)) - ((not (opt-long-name o)) + ((not (or (opt-short-name o) + (opt-long-name o))) (when newlinep (terpri stream) (setf newlinep nil)) @@ -1007,12 +1008,14 @@ (defun show-options-help (opts &optional (stream *standard-output*)) (doc (setf newlinep t) (pprint-logical-block (stream nil :prefix " ") - (format stream "~:[ ~;-~:*~C,~] --~A" + (format stream "~:[ ~;-~:*~C~:[~;,~]~:*~]~@[ --~A~]" (opt-short-name o) (opt-long-name o)) (when (opt-arg-name o) - (format stream "~:[=~A~;[=~A]~]" + (format stream + "~:[~;[~]~:[~0@*~:[ ~;~]~*~;=~]~A~0@*~:[~;]~]" (opt-arg-optional-p o) + (opt-long-name o) (opt-arg-name o))) (write-string " " stream) (pprint-tab :line 30 1 stream) -- [mdw]