X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/2ef055fe6ca5f97b0f3d57ad3675e4ac09210266..9252626a58343d3256feb3b8c0456749ec1b4300:/src/optparse.lisp diff --git a/src/optparse.lisp b/src/optparse.lisp index 2234595..1de6dfe 100644 --- a/src/optparse.lisp +++ b/src/optparse.lisp @@ -83,7 +83,7 @@ #+ecl (loop for i from 1 below (ext:argc) collect (ext:argv i)))) - (error "Unsupported Lisp.")))))) + (error "Unsupported Lisp")))))) *program-name* (pathname-name (car *command-line*)))) @@ -207,7 +207,7 @@ wrapped. If nil, the option is omitted from the help text. - Usually, one won't use make-option, but use the option macro instead." + Usually, one won't use `make-option', but use the `option' macro instead." (long-name nil :type (or null string)) (tag nil :type t) (negated-tag nil :type t) @@ -672,7 +672,7 @@ RADIX may be nil to allow radix prefixes, or an integer between 2 and 36. An option-parse-error is signalled if the ARG is not a valid integer, or if it is not between MIN and MAX (either of which may be nil if no lower - resp. upper bound is wanted)." + or upper bound is wanted)." (multiple-value-bind (v end) (parse-c-integer arg :radix radix) (unless (and v (>= end (length arg))) (option-parse-error "Bad integer `~A'" arg)) @@ -896,11 +896,8 @@ ;;; Support stuff for help and usage messages. (defun print-text (string - &optional - (stream *standard-output*) - &key - (start 0) - (end nil)) + &optional (stream *standard-output*) + &key (start 0) (end nil)) "Prints STRING to a pretty-printed STREAM, breaking it at whitespace and newlines in the obvious way. Stuff between square brackets is not broken: this makes usage messages work better." @@ -1000,22 +997,25 @@ (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)) (pprint-logical-block (stream nil) (print-text doc stream)) (terpri stream)) - (t + (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)