Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gibbed/ndesk.options
A (slightly) modified fork of NDesk.Options.
https://github.com/gibbed/ndesk.options
c-sharp option-parser
Last synced: 5 days ago
JSON representation
A (slightly) modified fork of NDesk.Options.
- Host: GitHub
- URL: https://github.com/gibbed/ndesk.options
- Owner: gibbed
- License: mit
- Created: 2012-04-11T02:20:09.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2021-10-08T06:47:01.000Z (about 3 years ago)
- Last Synced: 2024-11-01T00:51:36.485Z (12 days ago)
- Topics: c-sharp, option-parser
- Language: C#
- Homepage:
- Size: 27.3 KB
- Stars: 20
- Watchers: 6
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
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 ();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 names = new List ();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); });