getOpt package:extensible

Parse option arguments.
An all-in-one utility function. When there's an error, print it along with the usage info to stderr and terminate with exitFailure.