getopt
Simplified getopt, based on Svenne Panne's Haskell GetOpt

TODO: Sort out the packaging. Option is tedious to type, but
surely Option shouldn't be in the root namespace?
TODO: Wrap all messages; do all wrapping in processArgs, not
usageInfo; use sdoc-like library (see string.format todos)

Usage:

options = Options {Option {...} ...}
getopt.processArgs ()

Assumes prog = {name[, banner] [, purpose] [, notes] [, usage]}

options take a single dash, but may have a double dash
arguments may be given as -opt=arg or -opt arg
if an option taking an argument is given multiple times, only the
last value is returned; missing arguments are returned as 1

getOpt, usageInfo and dieWithUsage can be called directly (see
below, and the example at the end). Set _DEBUG.std to a non-nil
value to run the example.

getOpt: perform argument processing
argIn: list of command-line args
options: options table
returns
argOut: table of remaining non-options
optOut: table of option key-value list pairs
errors: table of error messages

Options table type

Options table constructor: adds lookup tables for the option names

Error and usage information formatting

errNoArg: argument when there shouldn't be one
@paramoptStr: option string
returns
err: option error

errReqArg: required argument missing
optStr: option string
desc: argument description
returns
err: option error

errUnrec: unrecognized option
optStr: option string
returns
err: option error

usageInfo: produce usage info for the given options
header: header string
optDesc: option descriptors
pageWidth: width to format to [78]
returns
mess: formatted string

dieWithUsage: die emitting a usage message

processArgs: simple getOpt wrapper
adds -version/-v and -help/-h/-? automatically; stops program
if there was an error or -help was used

A small and hopefully enlightening example: