Fix group help text not showing up in help
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 18 May 2019 13:35:43 -0400 |
parents |
8fa95046ae97
|
children |
c0e14a25c572
|
branches/tags |
(none) |
files |
docs/01-usage.markdown src/main.lisp |
Changes
--- a/docs/01-usage.markdown Fri May 17 23:28:15 2019 -0400
+++ b/docs/01-usage.markdown Sat May 18 13:35:43 2019 -0400
@@ -400,8 +400,7 @@
(defun build ()
(sb-ext:save-lisp-and-die "search" :executable t :toplevel #'toplevel))
-This is a typical way to use Adopt. There are three functions important
-functions here:
+This is a typical way to use Adopt. There are three important functions here:
* The `toplevel` function takes care of parsing arguments and exiting with an
appropriate status code if necessary.
@@ -713,10 +712,10 @@
(defparameter *option-no-literal*
(adopt:make-option 'no-literal
+ :result-key 'literal
:help "treat PATTERN as a regex (the default)"
:long "no-literal"
:short #\L
- :result-key 'literal
:reduce (constantly nil)))
(defparameter *option-case-sensitive*
@@ -758,10 +757,10 @@
:reduce #'adopt:last
:key #'parse-integer))
+
(defparameter *group-matching*
(adopt:make-group 'matching-options
:title "Matching Options"
- :help "These options affect how lines are matched."
:options (list *option-literal*
*option-no-literal*
*option-case-sensitive*
@@ -770,11 +769,12 @@
(defparameter *group-output*
(adopt:make-group 'output-options
:title "Output Options"
- :help "These options affect how matching lines are printed."
+ :help "These options affect how matching lines are printed. The defaults are ideal for piping into other programs."
:options (list *option-color*
*option-no-color*
*option-context*)))
+
(adopt:define-string *help-text*
"Search FILEs for lines that match the regular expression ~
PATTERN and print them to standard out. Several options ~
@@ -823,9 +823,13 @@
; ignore case when matching
;
; Output Options:
+ ;
+ ; These options affect how matching lines are printed. The
+ ; defaults are ideal for piping into other programs.
+ ;
; --color highlight matches with color
; --no-color don't highlight matches (the default)
- ; -U N, --context N show N lines of context (default 0)
+ ; -u N, --context N show N lines of context (default 0)
Error Handling
--------------
--- a/src/main.lisp Fri May 17 23:28:15 2019 -0400
+++ b/src/main.lisp Sat May 18 13:35:43 2019 -0400
@@ -477,10 +477,16 @@
(dolist (group (groups interface))
(when (options group)
(format stream "~%~A:~%" (or (title group) (name group) "Options"))
- (let* ((option-column 2)
+ (let* ((help (help group))
+ (help-column 2)
+ (help-width (- width help-column))
+ (option-column 2)
(option-padding 2)
(doc-column (+ option-column option-width option-padding))
(doc-width (- width doc-column)))
+ (when help
+ (format stream "~%~{ ~A~^~%~}~2%"
+ (bobbin:wrap (list help) help-width)))
(dolist (option (options group))
(print-option-help stream option option-column doc-column doc-width)))))
(let* ((examples (examples interface))