Skip to content
Snippets Groups Projects
Commit 19a6f3f0 authored by Martin Nilsson's avatar Martin Nilsson
Browse files

Some notes about Arg.

Rev: CHANGES:1.89
parent 4c1903e0
No related branches found
No related tags found
No related merge requests found
...@@ -543,6 +543,32 @@ o ADT.Set ...@@ -543,6 +543,32 @@ o ADT.Set
and code readability. and code readability.
o Arg o Arg
The new argument parser module allows for Getopt style arugment
parsing, but with a much simpler and object oriented API.
class Parser
{
inherit Arg.Options;
Opt verbose = NoOpt("-v")|NoOpt("--verbose")|Env("VERBOSE");
Opt name = HasOpt("-f")|HasOpt("--file")|Default("out");
Opt debug = MaybeOpt("-d")|MaybeOpt("--debug");
}
void main(int argc, array(string) argv)
{
Parser p = Parser(argv);
werror("name: %O, verbose: %O, debug: %O\n",
p->name, p->verbose, p->debug);
}
A more simplistic interface is also available for smaller hacks and
programs.
void main(int argc, array(string) argv)
{
mapping opts = Arg.parse(argv);
argv = opts[Arg.REST];
}
o Protocols.DNS_SD o Protocols.DNS_SD
This module provides an interface to DNS Service Discovery. The This module provides an interface to DNS Service Discovery. The
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment