chiark / gitweb /
frontend.lisp: Add hooks for extensions to add new command-line options.
[sod] / src / optparse.lisp
index 6460c54ae0b27cc777796ee127a71fc797a52e19..5017fe4daaa769f26a34d1c6fc8eceb59469af08 100644 (file)
@@ -85,7 +85,7 @@ (defun set-command-line-arguments ()
                                                  collect (ext:argv i))))
                               (error "Unsupported Lisp"))))))
 
-         *program-name* (pathname-name (car *command-line*))))
+       *program-name* (pathname-name (car *command-line*))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Fancy conditionals.
@@ -165,7 +165,7 @@ (defstruct (option
                          (opt-long-name o)
                          (opt-arg-optional-p o)
                          (opt-arg-name o)
-                         (opt-documentation o)))))
+                         (opt-%documentation o)))))
             (:constructor %make-option
                 (&key long-name tag negated-tag short-name
                       arg-name arg-optional-p documentation
@@ -207,7 +207,7 @@ (defstruct (option
                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)
@@ -896,11 +896,8 @@ (defmacro options (&rest optlist)
 ;;; 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 @@ (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))
               (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)