/// <summary> /// Returns a formatted string describing this option and its aliases. /// </summary> /// <param name="indent">The indentation to use.</param> /// <param name="nameColumnWidth">Width of the name column.</param> /// <param name="descriptionColumnWidth">Width of the description column.</param> /// <returns>a formatted string describing this option and its aliases that is suitable for displaying /// as a help message.</returns> public string ToString(int indent, int nameColumnWidth, int descriptionColumnWidth) { if (nameColumnWidth < 1) { throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, Plossum.Resources.CommandLineStrings.ArgMustBeGreaterThanZero, "nameColumnWidth"), "nameColumnWidth"); } if (descriptionColumnWidth < 1) { throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, Plossum.Resources.CommandLineStrings.ArgMustBeGreaterThanZero, "descriptionColumnWidth"), "descriptionColumnWidth"); } if (indent < 0) { throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, Plossum.Resources.CommandLineStrings.ArgMustBeNonNegative, "indent"), "indent"); } StringBuilder names = new StringBuilder(); names.Append(Name); foreach (string alias in mOption.Aliases) { names.Append(", "); names.Append(OptionStyleManager.PrefixOptionForDescription(mOptionStyles, alias)); } ColumnInfo nameColumn = new ColumnInfo(nameColumnWidth, names.ToString(), Alignment.Left); ColumnInfo descColumn = new ColumnInfo(descriptionColumnWidth, Description ?? "e", Alignment.Left, VerticalAlignment.Bottom); return(StringFormatter.FormatInColumns(indent, mUsageInfo.ColumnSpacing, nameColumn, descColumn)); }
/// <summary> /// Initializes a new instance of the <see cref="OptionInfo"/> class. /// </summary> /// <param name="usageInfo">The <see cref="UsageInfo" /> creating this OptionInfo</param> /// <param name="option">The option.</param> /// <param name="optionStyle">The option style.</param> internal OptionInfo(UsageInfo usageInfo, Option option, OptionStyles optionStyle) { mOption = option; mOptionStyles = optionStyle; mUsageInfo = usageInfo; foreach (string alias in mOption.Aliases) { mAliases.Add(OptionStyleManager.PrefixOptionForDescription(mOptionStyles, alias)); } }