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:
- table of remaining non-options
- table of option key-value list pairs
- 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