public void WriteOptionDescriptions(TextWriter o) { foreach (Option p in (Collection <Option>) this) { int written = 0; if (!p.Hidden) { if (p is OptionSet.Category) { this.WriteDescription(o, p.Description, "", 80, 80); } else if (this.WriteOptionPrototype(o, p, ref written)) { if (written < 29) { o.Write(new string(' ', 29 - written)); } else { o.WriteLine(); o.Write(new string(' ', 29)); } this.WriteDescription(o, p.Description, new string(' ', 31), 51, 49); } } } foreach (ArgumentSource argumentSource in this.sources) { string[] names = argumentSource.GetNames(); if (names != null && names.Length != 0) { int n = 0; OptionSet.Write(o, ref n, " "); OptionSet.Write(o, ref n, names[0]); for (int index = 1; index < names.Length; ++index) { OptionSet.Write(o, ref n, ", "); OptionSet.Write(o, ref n, names[index]); } if (n < 29) { o.Write(new string(' ', 29 - n)); } else { o.WriteLine(); o.Write(new string(' ', 29)); } this.WriteDescription(o, argumentSource.Description, new string(' ', 31), 51, 49); } } }
private bool WriteOptionPrototype(TextWriter o, Option p, ref int written) { string[] names = p.Names; int nextOptionIndex1 = OptionSet.GetNextOptionIndex(names, 0); if (nextOptionIndex1 == names.Length) { return(false); } if (names[nextOptionIndex1].Length == 1) { OptionSet.Write(o, ref written, " -"); OptionSet.Write(o, ref written, names[0]); } else { OptionSet.Write(o, ref written, " --"); OptionSet.Write(o, ref written, names[0]); } for (int nextOptionIndex2 = OptionSet.GetNextOptionIndex(names, nextOptionIndex1 + 1); nextOptionIndex2 < names.Length; nextOptionIndex2 = OptionSet.GetNextOptionIndex(names, nextOptionIndex2 + 1)) { OptionSet.Write(o, ref written, ", "); OptionSet.Write(o, ref written, names[nextOptionIndex2].Length == 1 ? "-" : "--"); OptionSet.Write(o, ref written, names[nextOptionIndex2]); } if (p.OptionValueType == OptionValueType.Optional || p.OptionValueType == OptionValueType.Required) { if (p.OptionValueType == OptionValueType.Optional) { OptionSet.Write(o, ref written, this.localizer("[")); } OptionSet.Write(o, ref written, this.localizer("=" + OptionSet.GetArgumentName(0, p.MaxValueCount, p.Description))); string str = p.ValueSeparators == null || p.ValueSeparators.Length <= 0 ? " " : p.ValueSeparators[0]; for (int index = 1; index < p.MaxValueCount; ++index) { OptionSet.Write(o, ref written, this.localizer(str + OptionSet.GetArgumentName(index, p.MaxValueCount, p.Description))); } if (p.OptionValueType == OptionValueType.Optional) { OptionSet.Write(o, ref written, this.localizer("]")); } } return(true); }