stillhq.com : Mikal, a geek from Canberra living in Silicon Valley http://www.stillhq.com The life, times, travel and software of Michael Still en Copyright (c) Michael Still 2000 - 2006 blosxom simplerss20 v20050208hh 180 http://blogs.law.harvard.edu/tech/rss GetOpt# 0.1 /getopt Thu, 14 Apr 2005 00:30:00 PST I'm in need of something like getopt for C#, and couldn't find one Googling. getopt provides standard Unix style command line parsing, which is what this version does as well. This version is very simple and only implements the short version of command line options. I'll implement long command line options later... <br/><br/> Here's a sample usage: <br/><br/> <ul><pre> bool verbose = false; string input = ""; if(args.Length == 0) { Console.WriteLine("Usage: openpdfdescribe -v -i &lt;input pdf&gt;"); return; } GetOpt options = new GetOpt(args, "vi:"); Arg a = options.NextArg(); while(a != null) { switch(a.Flag) { case "-v": verbose = true; break; case "-i": input = a.Parameter; break; default: Console.WriteLine("Unknown command line option: " + a.Flag); Console.WriteLine("Usage: openpdfdescribe -v -i &lt;input pdf&gt;"); return; } a = options.NextArg(); } Console.WriteLine("Verbose = " + verbose); Console.WriteLine("Input = " + input); </pre></ul> <br/><br/> This code is released under the terms of the GNU LGPL. You can download the code from <a href="/getopt/source/01/getopt.tgz">here</a>. <br/><br/><i>Technorati tags for this post: <a href="http://technorati.com/tag/getopt" rel="tag">getopt</a> <a href="http://technorati.com/tag/dotnet" rel="tag">dotnet</a> <a href="http://technorati.com/tag/c#" rel="tag">c#</a> <a href="http://technorati.com/tag/opensource" rel="tag">opensource</a> </i> <a href="http://www.stillhq.com/getopt/000001.commentform.html">Comment</a> http://www.stillhq.com/getopt/000001.html http://www.stillhq.com/getopt/000001.html