public void ConfigureReport(string[] aArgs) { AppOption descr = theOptions["descr"]; string optPrefix = "-"; AppOption opt; string arg = ""; string val = ""; string next = ""; int len = aArgs.Length; for (int i = 0; i < len; i++) { arg = aArgs[i]; val = arg; if (arg.StartsWith(optPrefix)) { arg = arg.Replace(optPrefix, "").Replace("/", ""); next = (i + 1 < len ? aArgs[i + 1] : ""); val = (next.Length > 0 && next.StartsWith(optPrefix) == false ? aArgs[++i] : ""); } if (theOptions.ContainsKey(arg)) { opt = theOptions[arg]; opt.Set(arg, val); } else { descr.Set(arg, val); } } }
public void Add(AppOption aOpt) { theList.Add(aOpt); theOptions[aOpt.ShortName] = aOpt; theOptions[aOpt.LongName] = aOpt; }
public string Usage() { StringBuilder usage = new StringBuilder(); AppOption descr = theOptions["descr"]; usage.AppendFormat("usage: {0} \"{1}\"", AppName, descr.HelpText); usage.Append("\n"); usage.AppendFormat("\n See options below for more details:"); usage.Append("\n"); foreach (AppOption opt in theList) { usage.AppendFormat("\n {0}", opt.Usage("-")); } return(usage.ToString()); }