Skip to content

Commit 2ffc280

Browse files
committed
Adding tests, fixes
1 parent 09f9ff3 commit 2ffc280

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/CommandLine.Tests/Unit/UnParserExtensionsTests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ public static void UnParsing_instance_with_fsharp_option_returns_command_line(Fa
3939
.ShouldBeEquivalentTo(result);
4040
}
4141

42+
[Fact]
43+
public static void UnParsing_instance_with_group_switches_returns_command_line_with_switches_grouped()
44+
{
45+
var options = new FakeOptionsWithSwitches { InputFile = "input.bin", HumanReadable = true, IgnoreWarnings = true };
46+
new Parser()
47+
.FormatCommandLine(options, config => config.GroupSwitches = true)
48+
.ShouldBeEquivalentTo("-hi --input input.bin");
49+
}
50+
4251
public static IEnumerable<object> UnParseData
4352
{ get {
4453
yield return new object[] { new FakeOptions(), "" };
@@ -83,5 +92,6 @@ public static IEnumerable<object> UnParseDataFSharpOption
8392
yield return new object[] { new FakeOptionsWithFSharpOption { Offset = FSharpOption<int>.Some(123456789) }, "123456789" };
8493
yield return new object[] { new FakeOptionsWithFSharpOption { FileName = FSharpOption<string>.Some("myfile.bin"), Offset = FSharpOption<int>.Some(123456789) }, "--filename myfile.bin 123456789" };
8594
}
86-
} }
95+
}
96+
}
8797
}

src/CommandLine/UnParserExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ orderby v.Index
115115
select info;
116116

117117
builder = settings.GroupSwitches && shortSwitches.Any()
118-
? builder.Append('-').Append(shortSwitches.Select(info => ((OptionSpecification)info.Specification).ShortName)).Append(' ')
118+
? builder.Append('-').Append(string.Join(string.Empty, shortSwitches.Select(
119+
info => ((OptionSpecification)info.Specification).ShortName).ToArray())).Append(' ')
119120
: builder;
120121
builder
121122
.TrimEndIfMatchWhen(!optSpecs.Any() || builder.TrailingSpaces() > 1, ' ');

0 commit comments

Comments
 (0)