Skip to content

Commit

Permalink
Fix help output for nested command-specific options.
Browse files Browse the repository at this point in the history
Closes #997.
  • Loading branch information
ashinn committed Aug 19, 2024
1 parent e09fdb7 commit 24b5837
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/chibi/app-test.sld
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@
(test 'error
(guard (exn (else 'error))
(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))))
2 changes: 1 addition & 1 deletion lib/chibi/app.scm
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@
(and (pair? (car ls)) (memq (caar ls) '(begin: end:) )))
(lp (cdr ls) (car ls) commands options))
((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)))
;; don't print nested commands
(if (pair? commands)
Expand Down

0 comments on commit 24b5837

Please sign in to comment.