Skip to content

Commit 11d59e6

Browse files
committed
Accept 'false' instead of just empty arity and add 0 arity test
1 parent ac1eae1 commit 11d59e6

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Cli/dotnet/Commands/Tool/Install/ToolInstallCommandParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal static class ToolInstallCommandParser
5151
public static readonly Option<bool> CreateManifestIfNeededOption = new("--create-manifest-if-needed")
5252
{
5353
Description = CliCommandStrings.CreateManifestIfNeededOptionDescription,
54-
Arity = ArgumentArity.Zero,
54+
Arity = ArgumentArity.ZeroOrOne,
5555
DefaultValueFactory = _ => true,
5656
};
5757

test/dotnet.Tests/CommandTests/Tool/Install/ToolInstallLocalCommandTests.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,33 @@ public void WhenRunWithPackageIdItShouldSaveToCacheAndAddToManifestFile()
127127
AssertDefaultInstallSuccess();
128128
}
129129

130+
[Fact]
131+
public void GivenCreateManifestIfNeededWithoutArgumentTheDefaultIsTrueForLegacyBehavior()
132+
{
133+
_fileSystem.File.Delete(_manifestFilePath);
134+
ParseResult parseResult =
135+
Parser.Instance.Parse(
136+
$"dotnet tool install {_packageIdA.ToString()} --create-manifest-if-needed");
137+
138+
var toolInstallLocalCommand = new ToolInstallLocalCommand(
139+
parseResult,
140+
_packageIdA,
141+
_toolPackageDownloaderMock,
142+
_toolManifestFinder,
143+
_toolManifestEditor,
144+
_localToolsResolverCache,
145+
_reporter);
146+
147+
toolInstallLocalCommand.Execute().Should().Be(0);
148+
}
149+
130150
[Fact]
131151
public void GivenNoManifestFileItShouldThrowAndContainNoManifestGuide()
132152
{
133153
_fileSystem.File.Delete(_manifestFilePath);
134154
ParseResult parseResult =
135155
Parser.Instance.Parse(
136-
$"dotnet tool install {_packageIdA.ToString()} --create-manifest-if-needed=false");
156+
$"dotnet tool install {_packageIdA.ToString()} --create-manifest-if-needed false");
137157

138158
var toolInstallLocalCommand = new ToolInstallLocalCommand(
139159
parseResult,

0 commit comments

Comments
 (0)