Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetOpt library for C#

Tags:

c#

getopt

I'm looking for a getopt library for c#. So far I found a few (phpguru, XGetOptCS, getoptfordotnet) but these look more like unfinished attempts that only support a part of C's getopt. Is there a full getopt c# implementation?

like image 973
Marijn Deé Avatar asked Oct 05 '08 18:10

Marijn Deé


People also ask

What is Optarg C?

optarg indicates an optional parameter to a command line option. opterr can be set to 0 to prevent getopt() from printing error messages. optind is the index of the next element of the argument list to be process, and optopt is the command line option last matched.

Why is getopt used?

The getopt() function is a builtin function in C and is used to parse command line arguments. Syntax: getopt(int argc, char *const argv[], const char *optstring) optstring is simply a list of characters, each representing a single character option.

What does getopt return?

RETURN VALUE The getopt() function returns the next option character specified on the command line. A colon (:) is returned if getopt() detects a missing argument and the first character of optstring was a colon (:).

Where is getopt defined?

The getopt() function is a command-line parser that shall follow Utility Syntax Guidelines 3, 4, 5, 6, 7, 9, and 10 in the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines. The parameters argc and argv are the argument count and argument array as passed to main() (see exec() ).


2 Answers

Miguel de Icaza raves about Mono.Options. You can use the nuget package, or just copy the single C# source file into your project.

like image 66
Wim Coenen Avatar answered Sep 22 '22 02:09

Wim Coenen


Here is a .NET Implementation of getopt: http://www.codeplex.com/getopt

like image 42
Thomas Avatar answered Sep 21 '22 02:09

Thomas