Skip to content

Commit 48c5699

Browse files
marcpopMSFTdsplaisted
authored andcommitted
Update based on PR feedback.
1 parent d15b933 commit 48c5699

19 files changed

+283
-85
lines changed

src/Cli/dotnet/Commands/CliCommandStrings.resx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,9 @@ If you would like to create a manifest, use the `--create-manifest-if-needed` fl
20522052
<data name="ToolRunCommandDescription" xml:space="preserve">
20532053
<value>Run a local tool. Note that this command cannot be used to run a global tool. </value>
20542054
</data>
2055+
<data name="ToolRunArguementsDescription" xml:space="preserve">
2056+
<value>Arguments forwarded to the tool</value>
2057+
</data>
20552058
<data name="ToolSearchCommandDescription" xml:space="preserve">
20562059
<value>Search dotnet tools in nuget.org</value>
20572060
</data>
@@ -2476,10 +2479,16 @@ To display a value, specify the corresponding command-line option without provid
24762479
<data name="SolutionAddReferencedProjectsOptionDescription" xml:space="preserve">
24772480
<value>Recursively add projects' ReferencedProjects to solution</value>
24782481
</data>
2479-
<data name="ToolRunFromSourceOptionDescription" xml:space="preserve">
2480-
<value>Executes a tool from source without permanently installing it. </value>
2482+
<data name="ToolExecuteCommandDescription" xml:space="preserve">
2483+
<value>Executes a tool from source without permanently installing it.</value>
2484+
</data>
2485+
<data name="ToolExecuteCommandMissingPackageId" xml:space="preserve">
2486+
<value>Missing package ID</value>
24812487
</data>
24822488
<data name="ToolRunFromSourceUserConfirmationPrompt" xml:space="preserve">
2483-
<value>Tool not found in the system. Do you want to run it from source? [y/n] </value>
2489+
<value>Tool not found on the system. Do you want to run it from source? [y/n]</value>
2490+
</data>
2491+
<data name="ToolRunFromSourceUserConfirmationFailed" xml:space="preserve">
2492+
<value>Run from source approval denied by the user</value>
24842493
</data>
24852494
</root>

src/Cli/dotnet/Commands/Tool/Execute/ToolExecuteCommand.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.DotNet.Cli.CommandFactory.CommandResolution;
77
using Microsoft.DotNet.Cli.Commands.Tool.Install;
88
using Microsoft.DotNet.Cli.ToolPackage;
9+
using Microsoft.DotNet.Cli.Utils;
910
using NuGet.Common;
1011
using NuGet.Packaging.Core;
1112
using NuGet.Versioning;
@@ -28,11 +29,17 @@ internal class ToolExecuteCommand(ParseResult result) : CommandBase(result)
2829

2930
public override int Execute()
3031
{
31-
if (!UserAgreedToRunFromSource() || _packageToolIdentityArgument is null)
32+
if (_packageToolIdentityArgument is null)
3233
{
34+
// System.CommandLine will throw an error if the argument is not provided, but we can still check here for clarity.
3335
return 1;
3436
}
3537

38+
if (!UserAgreedToRunFromSource())
39+
{
40+
throw new GracefulException(CliCommandStrings.ToolRunFromSourceUserConfirmationFailed, isUserError: true);
41+
}
42+
3643
if (_allowRollForward)
3744
{
3845
_forwardArguments.Append("--allow-roll-forward");

src/Cli/dotnet/Commands/Tool/Execute/ToolExecuteCommandParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal static class ToolExecuteCommandParser
1717

1818
public static readonly Argument<IEnumerable<string>> CommandArgument = new("commandArguments")
1919
{
20-
Description = "arguments forwarded to the tool"
20+
Description = CliCommandStrings.ToolRunArguementsDescription
2121
};
2222

2323
public static readonly Option<string> VersionOption = ToolInstallCommandParser.VersionOption;
@@ -40,7 +40,7 @@ public static Command GetCommand()
4040

4141
private static Command ConstructCommand()
4242
{
43-
Command command = new("execute", "Execute a tool command from source");
43+
Command command = new("execute", CliCommandStrings.ToolExecuteCommandDescription);
4444

4545
command.Aliases.Add("exec");
4646

src/Cli/dotnet/Commands/Tool/Run/ToolRunCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,4 @@ public override int Execute()
4444
var result = CommandFactoryUsingResolver.Create(commandSpec).Execute();
4545
return result.ExitCode;
4646
}
47-
48-
4947
}

src/Cli/dotnet/Commands/Tool/Run/ToolRunCommandParser.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#nullable disable
55

66
using System.CommandLine;
7-
using Microsoft.DotNet.Cli;
8-
using Microsoft.DotNet.Cli.Commands.Tool.Install;
9-
using Microsoft.DotNet.Cli.Commands.Tool.Common;
107

118
namespace Microsoft.DotNet.Cli.Commands.Tool.Run;
129

@@ -20,7 +17,7 @@ internal static class ToolRunCommandParser
2017

2118
public static readonly Argument<IEnumerable<string>> CommandArgument = new("toolArguments")
2219
{
23-
Description = "arguments forwarded to the tool"
20+
Description = CliCommandStrings.ToolRunArguementsDescription
2421
};
2522

2623
public static readonly Option<bool> RollForwardOption = new("--allow-roll-forward")
@@ -42,7 +39,6 @@ private static Command ConstructCommand()
4239

4340
command.Arguments.Add(CommandNameArgument);
4441
command.Arguments.Add(CommandArgument);
45-
4642
command.Options.Add(RollForwardOption);
4743

4844
command.SetAction((parseResult) => new ToolRunCommand(parseResult).Execute());

src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)