GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
dnsjit.lib.getopt(3) FreeBSD 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:

?
Make the option optional.
*
For string and number options this make it possible to specified it multiple times and all values will be returned in a table.
+
For number options this will act as an counter increaser, the value will be the default value + 1 for each time the option is given.

Option -h and --help are automatically added if the option --help is not already defined.

A table that contains the arguments left after parsing, same as returned by parse().
A string that describes the usage of the program, if not set then the default will be " program [options...] ".

Create a new Getopt object. args is a table with tables that specifies the options available. Each entry is unpacked and sent to Getopt:add().
Return the Log object to control logging of this instance or module.
Add an option.
Print the usage.
Parse the options. If args is not specified or nil then the global arg is used. If startn is given, it will start parsing arguments in the table from that position. The default position to start at is 2 for dnsjit, see dnsjit.core(3).
Return the value of an option.

dnsjit.core(3)

Jerry Lundström (DNS-OARC), Tomáš Křížek (CZ.NIC), Petr Špaček (ISC)

Maintained by DNS-OARC

https://www.dns-oarc.net/

For issues and feature requests please use:

https://github.com/DNS-OARC/dnsjit/issues

For question and help please use:

admin@dns-oarc.net
1.4.0 dnsjit

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.