tags:

views:

2740

answers:

7

Hi,

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?

A: 

I've a project which will need this sort of thing eventually too. I was wondering whether PowerShell exposed any of its argument processing in a nice way... might be worth a look.

Are you really after "getopt for C#" or do you want an idiomatic, nice to work with argument parser for .NET? I would imagine a decent argument parser in .NET may well take advantage of things which couldn't be in getopt, such as declarative flags via attributes.

Jon Skeet
If you want something with attributes, look at mine :)
leppie
+1  A: 

It's not getopt, but you might try NConsoler. It uses attributes to define arguments and actions.

Matt
+1  A: 

Here is something I wrote, it works rather nice, and has quite a lot of features for the tiny amount of code. It is not getopts however, but it may suit your needs.

Feel free to ask some questions.

leppie
+1  A: 

The Mono Project has (or rather had) one based on attributes, but last I checked it was marked as obsolete. But since it's open source, you might be able to pull the code out and use it yourself.

Ian McLaird
The cmd line parser in Mono would be great in the BCL. I use it all the time and think it's great.
fatcat1111
+4  A: 

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

Thomas
+2  A: 

For posterity:

CommandParser is another one with a BSD license

Remco Schoeman
+7  A: 

Miguel de Icaza raves about Mono.Options. It is just a single C# source file, so you can just include it in your project without introducing any new dependencies.

Wim Coenen