HelpText 因使用针对 DefaultValue 的通用格式化函数而受苦。
问题是(参考最新稳定版)在 HelpText.cs 的第 702行:
if (option.HasDefaultValue)
{
option.HelpText = "(Default: {0}) ".FormatLocal(option.DefaultValue) + option.HelpText;
}
当前的开发分支(我认为可用)使用新的辅助私有方法(也从测试的角度涵盖)解决了它:
private static string FormatDefaultValue(object value)
{
if (value is bool)
{
return value.ToLocalString().ToLowerInvariant();
}
if (value is string)
{
return value.ToLocalString();
}
var asEnumerable = value as IEnumerable;
if (asEnumerable != null)
{
var builder = new StringBuilder();
foreach (var item in asEnumerable)
{
builder.Append(item.ToLocalString());
builder.Append(" ");
}
return builder.Length > 0 ? builder.ToString(0, builder.Length - 1) : string.Empty;
}
return value.ToLocalString();
}
要使用最新的开发分支:
git clone -b develop-1.9.8-beta https://github.com/gsscoder/commandline.git commandline-develop
For informations on its stability and how could change after first release, see here.
With this instructions should be easy also patch a fork of the current stable.