Skip to content

Commit da3e28e

Browse files
edvilmedsplaisted
authored andcommitted
Address pr comments
1 parent b9a03d2 commit da3e28e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ internal class ToolRunCommand(
3030
private readonly ILocalToolsResolverCache _localToolsResolverCache = new LocalToolsResolverCache();
3131
public override int Execute()
3232
{
33-
CommandSpec commandspec = _localToolsCommandResolver.ResolveStrict(new CommandResolverArguments()
33+
CommandSpec commandSpec = _localToolsCommandResolver.ResolveStrict(new CommandResolverArguments()
3434
{
3535
// since LocalToolsCommandResolver is a resolver, and all resolver input have dotnet-
3636
CommandName = $"dotnet-{_toolCommandName}",
3737
CommandArguments = _forwardArgument,
3838

3939
}, _allowRollForward);
4040

41-
if (commandspec == null && _fromSource)
41+
if (commandSpec == null && _fromSource && UserAgreedToExecuteFromSource())
4242
{
4343
return ExecuteFromSource();
4444
}
4545

46-
if (commandspec == null)
46+
if (commandSpec == null)
4747
{
4848
throw new GracefulException([string.Format(CliCommandStrings.CannotFindCommandName, _toolCommandName)], isUserError: false);
4949
}
5050

51-
var result = CommandFactoryUsingResolver.Create(commandspec).Execute();
51+
var result = CommandFactoryUsingResolver.Create(commandSpec).Execute();
5252
return result.ExitCode;
5353
}
5454

@@ -91,4 +91,11 @@ public int ExecuteFromSource()
9191

9292
return result.ExitCode;
9393
}
94+
95+
private bool UserAgreedToExecuteFromSource()
96+
{
97+
// TODO: Use a better way to ask for user input
98+
Console.WriteLine("Tool will be run from source. Accept? [yn]")
99+
return Console.ReadLine() == 'y';
100+
}
94101
}

0 commit comments

Comments
 (0)