Skip to content

Commit 6ec461c

Browse files
edvilmedsplaisted
authored andcommitted
Add command
1 parent 47d0bba commit 6ec461c

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.CommandLine;
5+
using Microsoft.DotNet.Cli.CommandFactory;
6+
using Microsoft.DotNet.Cli.CommandFactory.CommandResolution;
7+
using Microsoft.DotNet.Cli.Commands.Tool.Install;
8+
using Microsoft.DotNet.Cli.ToolManifest;
9+
using Microsoft.DotNet.Cli.Utils;
10+
using Microsoft.Extensions.EnvironmentAbstractions;
11+
using Microsoft.DotNet.Cli.ToolPackage;
12+
namespace Microsoft.DotNet.Cli.Commands.Tool.Runx;
13+
14+
internal class ToolRunxCommand(ParseResult result) : CommandBase(result)
15+
{
16+
private readonly string _toolCommandName = result.GetValue(ToolRunxCommandParser.CommandNameArgument);
17+
private readonly IEnumerable<string> _forwardArgument = result.GetValue(ToolRunxCommandParser.CommandArgument);
18+
public bool _allowRollForward = result.GetValue(ToolRunxCommandParser.RollForwardOption);
19+
20+
public override int Execute()
21+
{
22+
var tempDir = new DirectoryPath(PathUtilities.CreateTempSubdirectory());
23+
return 0;
24+
}
25+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.CommandLine;
5+
6+
namespace Microsoft.DotNet.Cli.Commands.Tool.Runx;
7+
8+
internal static class ToolRunxCommandParser
9+
{
10+
public static readonly CliArgument<string> CommandNameArgument = new("commandName")
11+
{
12+
HelpName = CliCommandStrings.CommandNameArgumentName,
13+
Description = CliCommandStrings.CommandNameArgumentDescription
14+
};
15+
16+
public static readonly CliArgument<IEnumerable<string>> CommandArgument = new("toolArguments")
17+
{
18+
Description = "arguments forwarded to the tool"
19+
};
20+
21+
public static readonly CliOption<bool> RollForwardOption = new("--allow-roll-forward")
22+
{
23+
Description = CliCommandStrings.RollForwardOptionDescription,
24+
Arity = ArgumentArity.Zero
25+
};
26+
27+
private static readonly CliCommand Command = ConstructCommand();
28+
29+
public static CliCommand GetCommand()
30+
{
31+
return Command;
32+
}
33+
34+
private static CliCommand ConstructCommand()
35+
{
36+
CliCommand command = new("run", CliCommandStrings.ToolRunCommandDescription);
37+
38+
command.Arguments.Add(CommandNameArgument);
39+
command.Arguments.Add(CommandArgument);
40+
command.Options.Add(RollForwardOption);
41+
42+
command.SetAction((parseResult) => new ToolRunxCommand(parseResult).Execute());
43+
44+
return command;
45+
}
46+
}

src/Cli/dotnet/Commands/Tool/ToolCommandParser.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.DotNet.Cli.Commands.Tool.List;
99
using Microsoft.DotNet.Cli.Commands.Tool.Restore;
1010
using Microsoft.DotNet.Cli.Commands.Tool.Run;
11+
using Microsoft.DotNet.Cli.Commands.Tool.Runx;
1112
using Microsoft.DotNet.Cli.Commands.Tool.Search;
1213
using Microsoft.DotNet.Cli.Commands.Tool.Uninstall;
1314
using Microsoft.DotNet.Cli.Commands.Tool.Update;
@@ -37,6 +38,7 @@ private static Command ConstructCommand()
3738
command.Subcommands.Add(ToolRunCommandParser.GetCommand());
3839
command.Subcommands.Add(ToolSearchCommandParser.GetCommand());
3940
command.Subcommands.Add(ToolRestoreCommandParser.GetCommand());
41+
command.Subcommands.Add(ToolRunxCommandParser.GetCommand());
4042

4143
command.SetAction((parseResult) => parseResult.HandleMissingCommand());
4244

0 commit comments

Comments
 (0)