/* * OptionParse Class: to parse command line arguments * * Author: Daniele Simonin * Created: 13 April 2006 * Site: http://www.melodycode.com * * Version: 1.0.0 */ using System; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Collections.Specialized; namespace CommandLine { /// Class OptionParse to parse command line arguments. public class OptionParse { /// Class Option to refer a single command line option. private class Option { public string short_o, long_o, dest, help, metavar; public bool requested, boolean; private static int maxL=0; public Option(string short_o, string long_o, string dest, string help, string metavar, bool requested, bool boolean) { this.short_o=short_o; this.long_o=long_o; this.dest=dest; this.help=help; if (!boolean) { this.metavar=metavar; } string c=short_o+" "+metavar+", "+long_o+" "+metavar; maxL=c.Length>maxL?c.Length:maxL; this.requested=requested; this.boolean=boolean; } private static string putspaces(string s,int index,int n) { string spaces=""; for (int i=0; ilDx) { int lim=help.Length/lDx; int index=0; for (int i=1; i<=lim; i++) { if (i==1) { index=lDx; } else { index+=lungMax; } help=putspaces(help, index, lSx); } } ritorno+=putspaces(help, 0, lSx-lungSx); if (help.Length!=lDx) ritorno+="\n"; #endregion return ritorno; } } private List