Skip to content

Commit

Permalink
Fix ParameterService to remove hyphens from resolving argument name
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Apr 25, 2019
1 parent be7d821 commit 763018e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion source/Nuke.Common.Tests/ParameterServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void TestConversion(string argument, Type destinationType, object expecte
[Theory]
[InlineData("MSBuildConfiguration", typeof(string), "msbcfg")]
[InlineData("dockerConfiguration", typeof(string), "dkrcfg")]
[InlineData("publish-dir", typeof(string), "dir")]
public void TestSplitted(string argument, Type destinationType, object expectedValue)
{
GetService(
Expand All @@ -60,7 +61,9 @@ public void TestSplitted(string argument, Type destinationType, object expectedV
"-msbuild-configuration",
"msbcfg",
"-docker-configuration",
"dkrcfg"
"dkrcfg",
"--publish-dir",
"dir"
}).GetCommandLineArgument(argument, destinationType).Should().Be(expectedValue);
}

Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Common/Execution/ParameterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public object GetPositionalCommandLineArguments(Type destinationType, char? sepa
return GetDefaultValue(destinationType);

return ConvertCommandLineArguments(
$"$all-positional",
"$all-positional",
positionalArguments,
destinationType,
_commandLineArguments,
Expand Down Expand Up @@ -204,7 +204,7 @@ private bool HasCommandLineArgument(string argumentName, bool checkNames)
private int GetCommandLineArgumentIndex(string argumentName, bool checkNames)
{
var index = Array.FindLastIndex(_commandLineArguments,
x => x.StartsWith("-") && x.Replace("-", string.Empty).EqualsOrdinalIgnoreCase(argumentName));
x => x.StartsWith("-") && x.Replace("-", string.Empty).EqualsOrdinalIgnoreCase(argumentName.Replace("-", string.Empty)));

if (index == -1 && checkNames)
{
Expand Down

0 comments on commit 763018e

Please sign in to comment.