diff --git a/CliFx/Internal/Extensions.cs b/CliFx/Internal/Extensions.cs index fe6baa6..9184c88 100644 --- a/CliFx/Internal/Extensions.cs +++ b/CliFx/Internal/Extensions.cs @@ -23,8 +23,8 @@ namespace CliFx.Internal return index < 0 ? s : s.Substring(0, index); } - public static StringBuilder AppendIfEmpty(this StringBuilder builder, char value) => - builder.Length == 0 ? builder.Append(value) : builder; + public static StringBuilder AppendIfNotEmpty(this StringBuilder builder, char value) => + builder.Length > 0 ? builder.Append(value) : builder; public static TValue GetValueOrDefault(this IReadOnlyDictionary dic, TKey key) => dic.TryGetValue(key, out var result) ? result : default; diff --git a/CliFx/Models/CommandInput.cs b/CliFx/Models/CommandInput.cs index afa5676..828ca8c 100644 --- a/CliFx/Models/CommandInput.cs +++ b/CliFx/Models/CommandInput.cs @@ -63,7 +63,7 @@ namespace CliFx.Models foreach (var option in Options) { - buffer.AppendIfEmpty(' '); + buffer.AppendIfNotEmpty(' '); buffer.Append(option); } diff --git a/CliFx/Models/CommandOptionInput.cs b/CliFx/Models/CommandOptionInput.cs index 1f2ead7..9ad6447 100644 --- a/CliFx/Models/CommandOptionInput.cs +++ b/CliFx/Models/CommandOptionInput.cs @@ -54,7 +54,7 @@ namespace CliFx.Models foreach (var value in Values) { - buffer.AppendIfEmpty(' '); + buffer.AppendIfNotEmpty(' '); var isEscaped = value.Contains(" "); diff --git a/CliFx/Models/CommandSchema.cs b/CliFx/Models/CommandSchema.cs index acb4059..79e043e 100644 --- a/CliFx/Models/CommandSchema.cs +++ b/CliFx/Models/CommandSchema.cs @@ -51,7 +51,7 @@ namespace CliFx.Models foreach (var option in Options) { - buffer.AppendIfEmpty(' '); + buffer.AppendIfNotEmpty(' '); buffer.Append('['); buffer.Append(option); buffer.Append(']');