internal string ToString(WriteUsageOptions options) { string argumentName = _parser.ArgumentNamePrefixes[0] + ArgumentName; if (Position != null) { argumentName = string.Format(CultureInfo.CurrentCulture, options.OptionalArgumentFormat, argumentName); // for positional parameters, the name itself is optional } string argument = argumentName; if (!IsSwitch) { char separator = (_parser.AllowWhiteSpaceValueSeparator && options.UseWhiteSpaceValueSeparator) ? ' ' : CommandLineParser.NameValueSeparator; string argumentValue = string.Format(CultureInfo.CurrentCulture, options.ValueDescriptionFormat, ValueDescription); argument = argumentName + separator + argumentValue; } if (IsMultiValue) { argument += options.ArraySuffix; } if (IsRequired) { return(argument); } else { return(string.Format(CultureInfo.CurrentCulture, options.OptionalArgumentFormat, argument)); } }
/// <summary> /// Initializes a new instance of the <see cref="CreateShellCommandOptions"/> class. /// </summary> public CreateShellCommandOptions() { AllowWhiteSpaceValueSeparator = true; UsageOptions = new WriteUsageOptions(); CommandDescriptionIndent = 8; ArgumentNameComparer = StringComparer.OrdinalIgnoreCase; CommandNameComparer = StringComparer.OrdinalIgnoreCase; }
internal string ToString(WriteUsageOptions options) { string argumentName = _parser.ArgumentNamePrefixes[0] + ArgumentName; if (Position != null) { argumentName = string.Format(CultureInfo.CurrentCulture, options.OptionalArgumentFormat, argumentName); // for positional parameters, the name itself is optional } if (options.IncludeAliasInCommandLine && Aliases != null) { foreach (var alias in Aliases) { argumentName = argumentName + "|" + _parser.ArgumentNamePrefixes[0] + alias; } } string argument = argumentName; if (!IsSwitch) { char separator = (_parser.AllowWhiteSpaceValueSeparator && options.UseWhiteSpaceValueSeparator) ? ' ' : CommandLineParser.NameValueSeparator; string argumentValue = string.Format(CultureInfo.CurrentCulture, options.ValueDescriptionFormat, ValueDescription); if (ArgumentType.IsEnum && options.IncludeEnumValueListInCommandLine) { argumentValue = string.Format(CultureInfo.CurrentCulture, options.ValueDescriptionFormat, string.Join(",", Enum.GetNames(ArgumentType))); } argument = argumentName + separator + argumentValue; } if (IsMultiValue) { argument += options.ArraySuffix; } if (IsRequired) { return(argument); } else { return(string.Format(CultureInfo.CurrentCulture, options.OptionalArgumentFormat, argument)); } }