dnsjit.lib.getopt(3) | Library Functions Manual | dnsjit.lib.getopt(3) |
dnsjit.lib.getopt - Parse and handle arguments
local getopt = require("dnsjit.lib.getopt").new({
{ "v", "verbose", 0, "Enable verbosity",
"?+" },
{ nil, "host", "localhost", "Set host",
"?" },
{ "p", nil, 53, "Set port", "?" },
})
local left = getopt:parse()
print("host", getopt:val("host"))
print("port", getopt:val("p"))
A "getopt long" implementation to easily handle command line arguments and display usage. An option is the short name (one character), long name, default value (which also defines the type), help text and extensions. Options are by default required, see extensions to change this.
The Lua types allowed are boolean, string, number.
The extensions available are:
Option -h and --help are automatically added if the option --help is not already defined.
Jerry Lundström (DNS-OARC), Tomáš Křížek (CZ.NIC), Petr Špaček (ISC)
Maintained by DNS-OARC
For issues and feature requests please use:
For question and help please use:
1.2.3 | dnsjit |