Skip to content

Commit 4980cd4

Browse files
committed
better command attribution
1 parent f342f22 commit 4980cd4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Cli/dotnet/Program.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ private static void SetupMSBuildEnvironmentInvariants()
198198

199199
private static string GetCommandName(ParseResult r)
200200
{
201+
if (r.Action is Parser.PrintVersionAction)
202+
{
203+
// If the action is PrintVersionAction, we return the command name as "dotnet --version"
204+
return "dotnet --version";
205+
}
206+
else if (r.Action is Parser.PrintInfoAction)
207+
{
208+
// If the action is PrintHelpAction, we return the command name as "dotnet --help"
209+
return "dotnet --info";
210+
}
211+
201212
// walk the parent command tree to find the top-level command name and get the full command name for this parseresult
202213
List<string> parentNames = [r.CommandResult.Command.Name];
203214
var current = r.CommandResult.Parent;

0 commit comments

Comments
 (0)