-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add "dotnet dnx" command as alias for "dotnet tool execute" #49425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… something. This won't allow those commands to show up in subcommand-help of their parents, however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for a hidden dotnet dnx
alias that forwards to dotnet tool execute
, integrates it into the CLI parser, and adjusts help generation to surface the new command.
- Registers the new
dnx
command inParser.cs
- Implements
DnxCommandParser
to mirror arguments/options for forward execution - Modifies
HelpBuilder.cs
to stop skipping hidden commands sodnx
appears in help
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/Cli/dotnet/Parser.cs | Imported and registered DnxCommandParser ; reorganized help option handling |
src/Cli/dotnet/Commands/Dnx/DnxCommandParser.cs | New hidden dnx command that forwards to ToolExecuteCommand |
src/Cli/Microsoft.TemplateEngine.Cli/Help/HelpBuilder.cs | Removed skip for hidden commands to allow help for dnx |
Comments suppressed due to low confidence (3)
src/Cli/Microsoft.TemplateEngine.Cli/Help/HelpBuilder.cs:45
- The check to skip hidden commands was removed, causing hidden commands (like
dnx
) to appear in help for all commands. Consider reintroducingif (context.Command.Hidden) { return; }
or conditionally checking the alias so other hidden commands stay hidden.
foreach (var writeSection in GetLayout(context))
src/Cli/dotnet/Commands/Dnx/DnxCommandParser.cs:20
- There are no tests added to verify that
dotnet dnx
correctly forwards to the underlyingdotnet tool execute
. Please add unit or integration tests to cover this new alias behavior.
Command command = new("dnx", CliCommandStrings.ToolExecuteCommandDescription);
src/Cli/dotnet/Parser.cs:314
- [nitpick] The root help text (
CliUsage.HelpText
) likely needs updating to mention the newdnx
alias so users know it’s available and how it maps todotnet tool execute
.
Console.Out.WriteLine(CliUsage.HelpText);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely like having a shorthand. That's awesome.
Before the .NET CLI / .NET SDK existed, the tool that used to be the SDK was called dnx
. I worry this will result in name confusion and would prefer to use dntx
, though I am not the 'decision maker' on this.
|
||
private static Command ConstructCommand() | ||
{ | ||
Command command = new("dnx", CliCommandStrings.ToolExecuteCommandDescription); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@baronfel Is this the only way to alias nested commands? Meaning, @dsplaisted is taking what is execute
nested in tool
, creating this composition of it called dnx
, and then exposing that as a new command. I'm assuming aliasing execute
would end up with dotnet tool dnx
. Also, does this composition work with the shell completion stuff since the options and arguments are copied over?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command
s can have aliases, but only at the 'same level'. This kind of sub-level redirect isn't natively supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the shell completion perspective this is an entirely new command with separate completions. If we had some more 'full' concept of aliases then the completion generation could perhaps handle that more intelligently.
See my response here: dotnet/designs#334 (comment)
My sense is that @baronfel, do you think this is correct or am I just projecting my own opinion? |
I think that's valid. preview 6 has snapped, so we may want to change the target branch if we can still get this in. I will bring this up in triage. Thanks for considering my feedback :) |
Triage: tool exec was the critical piece we wanted for P6. This is nice to have and we can wait for preview 7 when we can get dnx in for zip and admin installs. |
This adds a root
dotnet dnx
command which forwards todotnet tool execute
. This will enable us to add adnx
shell script which callsdotnet dnx
.