dotnet / dotnet/command-line-api

Missed options in help section

Open
#1,190 4 comments 15 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Missed options in help section when calling with `-h` argument

Way to reproduce:
```C#
private static async Task Main(string[] args)
{
var rootCommand = new RootCommand("Migration tool for SQL Database")
{
new Option(new[] { "--source-connection-string", "-scs" }, "Full connection string to source of database.") { IsRequired = true },
new Option(new[] { "--destination-connection-string", "-dcs" }, "Full connection string to source sql server, may contain master database name.") { IsRequired = true },
new Option(new[] { "--created-database-connection-string", "-cdcs" }, "Full connection string to destination database with specified name.") { IsRequired = true },
new Option(new[] { "--database-name", "-dn" }, "Name of destination database") { IsRequired = true },
};

var helpBuilder = (HelpBuilder)default;
rootCommand.TreatUnmatchedTokensAsErrors = true;
rootCommand.Handler = CommandHandler.Create(Migrate);

var commandLineBuilder = new CommandLineBuilder(rootCommand)
.UseTypoCorrections()
.UseParseErrorReporting()
.CancelOnProcessTermination()
.UseExceptionHandler()
.UseHelpBuilder(c =>
{
helpBuilder = new CustomHelpBuilder(c.Console);
return helpBuilder;
})
.Build();

await commandLineBuilder.InvokeAsync(args);
}
```

And then call executable with -h argument
Result of call

![image](https://user-images.githubusercontent.com/5252769/106996020-ec7de000-67a1-11eb-85c6-97bc54857e03.png)

When calling without any arguments

![image](https://user-images.githubusercontent.com/5252769/106996360-a70de280-67a2-11eb-8c8b-52b2c07010c7.png)

So how to display all options, when calling with `-h` or `--help` or `-?`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.