Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Exact Mirror of ndesk-options on github. Cause I don't want to remember too many URLs. This is a good optparse implementation in C#. See the original homepage for details.
JavaScript Shell
branch: master

Fix OutOfMemoryException caused by description text.

	* src/NDesk.Options/NDesk.Options/Options.cs: Viktor Lundgren reported
	  that Option.Description text of `"aaa." . "a" x 64` (that is, "aaa."
	  followed by 64 "a"s) would cause GetLines() to go into an infinite
	  loop and (eventually) die from an OutOfMemoryException.  Oops.
	  Fix this, simplify the logic, and turn GetLines() into an
	  IEnumerable<string>.
	* src/NDesk.Options/Test/NDesk.Options/OptionSetTest.cs: Add tests for
	  line breaking.
latest commit d6b6f26be1
@jonpryor jonpryor authored
Failed to load latest commit information.
doc
lib Add support for nullable types to OptionSet.Add().
src/NDesk.Options Fix OutOfMemoryException caused by description text.
.gitignore
AUTHORS Autotool-ify the build system.
COPYING
ChangeLog
INSTALL
Makefile.am
NEWS Autotool-ify the build system.
README
autogen.sh Autotool-ify the build system.
configure.ac
ndesk-options.spec.in Updates to simplify deployments to ndesk.org...

README

NDesk.Options
=============

NDesk.Options is a program option parser for C#.

See: http://www.ndesk.org/Options

Overview:
--------

It takes advantage of C# 3.0 features such as collection initializers and
lambda delegates to provide a short, concise specification of the option 
names to parse, whether or not those options support values, and what to do 
when the option is encountered.  It's entirely callback based:

	var verbose = 0;
	var show_help = false;
	var names = new List<string> ();

	var p = new OptionSet () {
		{ "v|verbose", v => { if (v != null) ++verbose; } },
		{ "h|?|help",  v => { show_help = v != null; } },
		{ "n|name=",   v => { names.Add (v); } },
	};

However, C# 3.0 features are not required, and can be used with C# 2.0:

	int          verbose   = 0;
	bool         show_help = false;
	List<string> names     = new List<string> ();

	OptionSet p = new OptionSet ()
	  .Add ("v|verbose", delegate (string v) { if (v != null) ++verbose; })
	  .Add ("h|?|help",  delegate (string v) { show_help = v != null; })
	  .Add ("n|name=",   delegate (string v) { names.Add (v); });


Distribution:
------------

In accordance with the Guidelines for Application Deployment [0], there are
pkg-config files to permit simple access to the source or pre-compiled
assemblies for re-use.

There are two ways to use NDesk.Options:

	- Bundle src/NDesk.Options/NDesk.Options/Options.cs with your app.

		pkg-config --variable=Sources ndesk-options

	- Use a prebuilt NDesk.Options.dll:

		pkg-config --variable=Libraries ndesk-options

[0] http://www.mono-project.com/Guidelines:Application_Deployment#Libraries_with_Unstable_APIs
Something went wrong with that request. Please try again.