Skip to content

Commit f689647

Browse files
edvilmedsplaisted
authored andcommitted
Add options
1 parent 0ea6696 commit f689647

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.CommandLine;
77
using Microsoft.DotNet.Cli.Commands.Tool.Install;
8+
using Microsoft.DotNet.Cli.Commands.Tool.Common;
89

910
namespace Microsoft.DotNet.Cli.Commands.Tool.Run;
1011

@@ -33,6 +34,14 @@ internal static class ToolRunCommandParser
3334
Arity = ArgumentArity.Zero
3435
};
3536

37+
public static readonly Option<string> FromSourceConfigFile = ToolInstallCommandParser.ConfigOption;
38+
39+
public static readonly Option<string[]> FromSourceSourceOption = ToolInstallCommandParser.SourceOption;
40+
41+
public static readonly Option<string[]> FromSourceAddSourceOption = ToolInstallCommandParser.AddSourceOption;
42+
43+
public static readonly Option<VerbosityOptions> VerbosityOption = CommonOptions.VerbosityOption;
44+
3645
private static readonly Command Command = ConstructCommand();
3746

3847
public static Command GetCommand()
@@ -48,6 +57,13 @@ private static Command ConstructCommand()
4857
command.Arguments.Add(CommandArgument);
4958
command.Options.Add(RollForwardOption);
5059
command.Options.Add(FromSourceOption);
60+
command.Options.Add(FromSourceConfigFile);
61+
command.Options.Add(FromSourceSourceOption);
62+
command.Options.Add(FromSourceAddSourceOption);
63+
command.Options.Add(VerbosityOption);
64+
65+
command.Options.Add(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption);
66+
command.Options.Add(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption);
5167

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

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ internal class ToolRunFromSourceCommand(
1919
private readonly string? _toolCommandName = result.GetValue(ToolRunCommandParser.CommandNameArgument);
2020
private readonly IEnumerable<string>? _forwardArguments = result.GetValue(ToolRunCommandParser.CommandArgument);
2121
private readonly bool _allowRollForward = result.GetValue(ToolRunCommandParser.RollForwardOption);
22+
private readonly string? _configFile = result.GetValue(ToolRunCommandParser.FromSourceConfigFile);
23+
private readonly string[] _sources = result.GetValue(ToolRunCommandParser.FromSourceSourceOption) ?? [];
24+
private readonly string[] _addSource = result.GetValue(ToolRunCommandParser.FromSourceAddSourceOption) ?? [];
25+
private readonly bool _ignoreFailedSources = result.GetValue(ToolCommandRestorePassThroughOptions.IgnoreFailedSourcesOption);
26+
private readonly bool _interactive = result.GetValue(ToolCommandRestorePassThroughOptions.InteractiveRestoreOption);
27+
private readonly VerbosityOptions _verbosity = result.GetValue(ToolRunCommandParser.VerbosityOption);
2228

2329
public override int Execute()
2430
{
@@ -40,10 +46,17 @@ public override int Execute()
4046
ToolPackageDownloader toolPackageDownloader = new(toolPackageStoreAndQuery);
4147

4248
IToolPackage toolPackage = toolPackageDownloader.InstallPackage(
43-
new PackageLocation(),
49+
new PackageLocation(
50+
nugetConfig: _configFile != null ? new FilePath(_configFile) : null,
51+
rootConfigDirectory: null,
52+
sourceFeedOverrides: _sources,
53+
additionalFeeds: _addSource),
4454
packageId: packageId,
45-
verbosity: VerbosityOptions.d,
46-
versionRange: versionRange);
55+
verbosity: _verbosity,
56+
versionRange: versionRange,
57+
restoreActionConfig: new(
58+
IgnoreFailedSources: _ignoreFailedSources,
59+
Interactive: _interactive));
4760

4861
toolManifestEditor.Add(
4962
toolManifestPath,

0 commit comments

Comments
 (0)