dotnet / dotnet/command-line-api

Generating CLI tool usages

Open
#831 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Is there a way to get the usages generated to reflect that a program is intended to used as a CLI tool? What I would like to see is the `--help` switch return the following, similar to how `dotnet test` does.

I have tried setting the `RootCommand.Name` property to "dotnet mytool" but that threw an `ArgumentException` about whitespace. I have also looked at using a custom `IHelpBuilder`, but overriding `AddUsage` to add this is looking like a _lot_ of work.

Currently `--help` produces this:
```
C:\Users\Paul>dotnet mytool --help
mytool:
My Tool

Usage:
mytool [options]

Options:
--dry-run Executes the command without making any changes.
-?, -h, --help Show help and usage information
```

What I would like to see is:
```
C:\Users\Paul>dotnet mytool --help
mytool:
My Tool

Usage:
dotnet mytool [options]

Options:
--dry-run Executes the command without making any changes.
-?, -h, --help Show help and usage information
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing how RootCommand.Name is validated and how the default help builder, especially IHelpBuilder.AddUsage, formats the Usage section. Compare the current and requested --help output to determine where a multi-word invocation such as "dotnet mytool" could be represented. Done means the generated usage shows "dotnet mytool [options]" without requiring a custom help builder.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.