File getopt.lua

Functions

getOpt (argIn, options, stop_at_nonopt) Perform argument processing
makeOptions (t) Options table constructor: adds lookup tables for the option names
processArgs (prog, ...) Simple getOpt wrapper.
usage (prog) Emit a usage message.
usageInfo (header, optDesc, pageWidth) Produce usage info for the given options


Functions

getOpt (argIn, options, stop_at_nonopt)
Perform argument processing

Parameters

  • argIn: list of command-line args
  • options: options table
  • stop_at_nonopt: if true, stop option processing at first non-option

Return values:

  1. table of remaining non-options
  2. table of option key-value list pairs
  3. table of error messages
makeOptions (t)
Options table constructor: adds lookup tables for the option names

Parameters

  • t:
processArgs (prog, ...)
Simple getOpt wrapper. If the caller didn't supply their own already, adds --version/-V and --help/-h options automatically; stops program if there was an error, or if --help or --version was used.

Parameters

  • prog: table of named parameters
  • ...: extra arguments for getOpt
usage (prog)
Emit a usage message.

Parameters

  • prog: table of named parameters
usageInfo (header, optDesc, pageWidth)
Produce usage info for the given options

Parameters

  • header: header string
  • optDesc: option descriptors
  • pageWidth: width to format to [78]

Return value:

formatted string

Valid XHTML 1.0!