Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
dnsjit.lib.getopt(3)	    Library Functions Manual	    dnsjit.lib.getopt(3)

NAME
     dnsjit.lib.getopt - Parse and handle arguments

SYNOPSIS
       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"))

DESCRIPTION
     A	"getopt long" implementation to easily handle command line arguments and
     display usage.  An option is the short name (one character), long name, de-
     fault value (which also defines the type), help text and  extensions.   Op-
     tions 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.

   Attributes
     left   A table that contains the arguments left after parsing, same as  re-
	    turned by parse().

     usage_desc
	    A  string  that  describes the usage of the program, if not set then
	    the default will be " program [options...]	".

   Functions
     Getopt.new(args)
	    Create a new Getopt object.  args is a table with tables that speci-
	    fies the options available.  Each entry  is  unpacked  and	sent  to
	    Getopt:add().

     Getopt:log()
	    Return the Log object to control logging of this instance or module.

     Getopt:add(short, long, default, help, extensions)
	    Add an option.

     Getopt:usage()
	    Print the usage.

     Getopt:parse(args, startn)
	    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).

     Getopt:val(name)
	    Return the value of an option.

SEE ALSO
     dnsjit.core(3)

AUTHORS and CONTRIBUTORS
     Jerry LundstrA<paragraph>m (DNS-OARC),  TomA!A!  KAAA3/4ek  (CZ.NIC),  Petr
     A paAek (ISC)

     Maintained by DNS-OARC

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

BUGS
     For issues and feature requests please use:

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

     For question and help please use:

	    admin@dns-oarc.net

dnsjit				      1.4.0		    dnsjit.lib.getopt(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=dnsjit.lib.getopt&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help