(index ("make-usage" 0))
(def (sig (procedure "(make-usage helper)" (id make-usage))) (p "Returns a procedure that, when called, prints a usage message for the running program.  The usage message is the retun value of " (tt "helper") ", a one-argument procedure which receives the program name (with the directory stripped) as argument.") (p "The procedure returned by " (tt "make-usage") " can optionally be given a number which indicates the program's exit code.") (p "Here's an usage example of usage (considering the code below is in a file called " (tt "usage-test") "):") (highlight scheme "(use usage)\n\n(define usage\n  (make-usage\n   (lambda (program)\n     (print #<#EOH\nUsage: #{program} <options>\n\n<options> are:\n\n  -foo: foobarizes\n  -bar: barbarizes\nEOH\n))))\n\n(if (member \"-h\" (command-line-arguments))\n    (usage)\n    (usage 1))") (p "When run with th " (tt "-h") " command line argument, " (tt "usage-test") " prints the usage message to " (tt "(current-output-port)") ".  When run without command line options or with any option which is not " (tt "-h") ", " (tt "usage-test") " prints the usage message to " (tt "(current-error-port)") " and aborts the program with exit code " (tt "1") ".") (pre "$ csi -s usage-test -h\nUsage: usage-test <options>\n\n<options> are:\n\n  -foo: foobarizes\n  -bar: barbarizes"))
