镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Print help when a diagnostics tool is run without a command - #6132

Merged
rcj1 merged 1 commit into
dotnet:mainfrom
AsadIqbal-Dev:fix/tools-no-args-help
Oct 23, 2026
Merged

rcj1 merged 1 commit into
dotnet:mainfrom
AsadIqbal-Dev:fix/tools-no-args-help

Conversation

@AsadIqbal-Dev

Copy link
Copy Markdown
Contributor

Fixes #510

Running any of the tools with no arguments printed Required command was not provided. and exited with 1, because the root command has subcommands but no action. The System.CommandLine limitation mentioned in the issue (dotnet/command-line-api#653) is gone in the 2.0 API, so the root command can now be given HelpAction.

The change is the same one line in each tool: dotnet-counters, dotnet-trace, dotnet-dump, dotnet-gcdump, dotnet-stack, dotnet-dsrouter and dotnet-sos.

Checked each built tool by hand:

Tool no arguments bogus (unknown command) --version
dotnet-counters help, exit 0 (was error, exit 1) error, exit 1 exit 0
dotnet-trace help, exit 0 (was error, exit 1) error, exit 1 exit 0
dotnet-dump help, exit 0 (was error, exit 1) error, exit 1 exit 0
dotnet-gcdump help, exit 0 (was error, exit 1) error, exit 1 exit 0
dotnet-stack help, exit 0 (was error, exit 1) error, exit 1 exit 0
dotnet-dsrouter help, exit 0 (was error, exit 1) error, exit 1 exit 0
dotnet-sos help, exit 0 (was error, exit 1) error, exit 1 exit 0

Unknown commands and other parse errors still fail as before.

The root commands have subcommands but no action, so running a tool with no arguments failed with 'Required command was not provided.' Give each root command a HelpAction instead.

Fixes dotnet#510
@AsadIqbal-Dev
AsadIqbal-Dev requested a review from a team as a code owner October 22, 2026 20:29
@rcj1
rcj1 merged commit 8575f74 into dotnet:main Oct 23, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet tools shouldn't error if no arguments are provided

2 participants