Skip to content

Commit f1d2940

Browse files
committed
better command attribution
1 parent eda61da commit f1d2940

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
@@ -196,6 +196,17 @@ private static void SetupMSBuildEnvironmentInvariants()
196196

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

0 commit comments

Comments
 (0)