dotnet / dotnet/command-line-api

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

Aperta
#2,501 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
C#
Stelle
3.7k
Fork
428
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la riproduzione in Program.cs ed esegui le combinazioni di comandi --help/--version elencate per confermare le differenze nell’output. Poi traccia come la CLI gestisce gli argomenti di help e versione; il lavoro è concluso quando viene visualizzato l’errore previsto "--version option cannot be combined with other arguments." quando vengono fornite entrambe le opzioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
cli
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.