dotnet / dotnet/command-line-api
"--version option cannot be combined with other arguments." is not displayed when "--help" is also specified
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
Hi.
Thank you for System.CommandLine.
The error message "--version option cannot be combined with other arguments." is not displayed when "--help" is also specified on the command line.
Steps to reproduce:
1. Build console app with Program.cs:
```
internal class Program
{
static async Task Main(string[] args)
{
RootCommand rootCommand = new RootCommand();
var option = new Option("--option1");
rootCommand.Add(option);
rootCommand.Handler = CommandHandler.Create(() =>
{
Console.WriteLine("Hello, World!");
});
return await rootCommand.InvokeAsync(args);
}
}
```
2. Run `ConsoleApp1.exe --option1 --version`
Notice the error `--version option cannot be combined with other arguments.`
This is expected behavior.
3. Run `ConsoleApp10.exe --help --version`
Notice the error is not displayed.
Only the version is displayed.
This is unexpected behavior; I expected the error `--version option cannot be combined with other arguments.`.
4. Run `ConsoleApp10.exe --option1 --help --version`
Notice the error is not displayed.
Only the version is displayed.
This is unexpected behavior; I expected the error `--version option cannot be combined with other arguments.`.
System.CommandLine 2.0.0-beta4.22272.1
Thank you.
Contributor guide
Assessment
This issue has not been assessed yet.