Finish integrated command-line help system.

This commit is contained in:
Dominik Pantůček 2023-03-14 10:57:27 +01:00
parent 9a438758b3
commit d44dc759fc
2 changed files with 16 additions and 5 deletions

View file

@ -46,7 +46,10 @@
(command-line
print-help
(-h "This help" () (print "help") (print-help) (print "done") (exit 0))
(-h "This help" ()
(print "Command-line options:")
(print-help)
(exit 0))
(-a "One-argument" (x) (print "Argument x " x))
(-b "Two arguments" (x y) (print "Arguments " x y))
(-c "Argument lambda" (lambda (x) (print "Lambda x " x))))

View file

@ -100,10 +100,18 @@
descrs))))
(let loop ((descrs descrs))
(when (not (null? descrs))
(let ((desc (car descrs)))
(print (car desc)
(cadr desc)
(caddr desc))
(let* ((desc (car descrs))
(opt (car desc))
(args (cadr desc))
(help (caddr desc)))
(print " "
opt
(make-string (- owidth (string-length opt)) #\space)
" "
args
(make-string (- awidth (string-length args)) #\space)
" "
help)
(loop (cdr descrs)))))))
;; Syntax for expanding various types of options.