[Mono-dev] Program Option Parsing Library

Jonathan Pryor jonpryor at vt.edu
Thu Jan 10 17:49:05 EST 2008


On Thu, 2008-01-10 at 23:08 +0100, Leszek Ciesielski wrote:
> > There's a test for this -- see Test.CheckExceptions().  An
> > InvalidOperationException would be generated if --foo requires a value
> > and --bar is registered (i.e. "-a -a" throws).  If --bar is NOT
> > registered, then --foo gets the value --bar.
> 
> Sorry to cut in, but some unix utilities use -v to increase verbosity
> and accept it multiple times to increase the amount of information
> printed. I suppose your code does not permit this?

It's supported.  See Test.CheckMany() for an example, or this:

	int verbose = 0;
	var p = new Options () {
	  { "v", v => { ++verbose; } },
	};
	p.Parse (new string[]{"-v", "-v", "-v"}).ToArray ();
	Console.WriteLine (verbose); // should print 3

It's callback based.  It's very flexible.

 - Jon





More information about the Mono-devel-list mailing list