dotnet / dotnet/command-line-api

"--version option cannot be combined with other arguments." is not displayed when "--help" is also specified

Offen
#2,501 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C#
Sterne
3.7k
Forks
428
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der Reproduktion in Program.cs und führe die aufgeführten Kombinationen der Befehle --help/--version aus, um die unterschiedlichen Ausgaben zu bestätigen. Verfolge dann, wie die CLI Hilfe- und Versionsargumente verarbeitet; fertig ist die Untersuchung, wenn der erwartete Fehler "--version option cannot be combined with other arguments." angezeigt wird, sobald beide Optionen angegeben werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.