Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

usage

A very small and simple helper to create usage messages

Author

Mario Domenech Goulart

License

BSD

Requirements

None

Procedures

[procedure] (make-usage helper)

Returns a procedure that, when called, prints a usage message for the running program. The usage message is the retun value of helper, a one-argument procedure which receives the program name (with the directory stripped) as argument.

The procedure returned by make-usage can optionally be given a number which indicates the program's exit code.

Here's an usage example of usage (considering the code below is in a file called usage-test):

(use usage)

(define usage
  (make-usage
   (lambda (program)
     (print #<#EOH
Usage: #{program} <options>

<options> are:

  -foo: foobarizes
  -bar: barbarizes
EOH
))))

(if (member "-h" (command-line-arguments))
    (usage)
    (usage 1))

When run with th -h command line argument, usage-test prints the usage message to (current-output-port). When run without command line options or with any option which is not -h, usage-test prints the usage message to (current-error-port) and aborts the program with exit code 1.

$ csi -s usage-test -h
Usage: usage-test <options>

<options> are:

  -foo: foobarizes
  -bar: barbarizes

Version History

0.1
Initial release