Fix help output for nested command-specific options.

Closes #997.
This commit is contained in:
Alex Shinn 2024-08-19 22:24:03 +09:00
parent e09fdb7e31
commit 24b5837562
2 changed files with 7 additions and 2 deletions

View file

@ -41,4 +41,9 @@
(guard (exn (else 'error)) (guard (exn (else 'error))
(run-application zoo-app-spec (run-application zoo-app-spec
'("zoo" "--soap" "wash" "--animals" "rhino")))) '("zoo" "--soap" "wash" "--animals" "rhino"))))
(let ((out (open-output-string)))
(parameterize ((current-output-port out))
(run-application zoo-app-spec '("zoo" "help"))
(test "Usage: zoo [options] <command>\nCommands:\n feed animals ... - feed the animals\n wash animals ... - wash the animals\n help - print help\nOptions:\n --animals - list of animals to act on (default all)\n -l, --lions - also apply the action to lions\n"
(get-output-string out))))
(test-end)))) (test-end))))

View file

@ -538,7 +538,7 @@
(and (pair? (car ls)) (memq (caar ls) '(begin: end:) ))) (and (pair? (car ls)) (memq (caar ls) '(begin: end:) )))
(lp (cdr ls) (car ls) commands options)) (lp (cdr ls) (car ls) commands options))
((and (pair? (car ls)) (eq? '@ (caar ls))) ((and (pair? (car ls)) (eq? '@ (caar ls)))
(lp (cdr ls) docs commands (append options (cadr (car ls))))) (lp (cdr ls) docs commands (append options (cdar ls))))
((and (pair? (car ls)) (symbol? (caar ls))) ((and (pair? (car ls)) (symbol? (caar ls)))
;; don't print nested commands ;; don't print nested commands
(if (pair? commands) (if (pair? commands)