dotnet / dotnet/command-line-api
Consider using Option<T> in tutorial
- Lingua principale
- C#
- Stelle
- 3.7k
- Fork
- 428
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
As a new-comer to this library I find the first example in the tutorial a bit confusing. The fact that RootCommand is an enumerable is not immediately obvious, and there are way too many `{}` for my taste.
I think it would be nice to use `Option` in the tutorial, and writing the output in one line which gets rid of most of the noise:
```cs
var command = new RootCommand
{
new Option("--a-string"),
new Option("--an-int"),
};
command.Handler = CommandHandler.Create((string aString, int anInt) =>
Console.WriteLine($"aString: {aString}, anInt: {anInt}"));
await command.InvokeAsync("--a-string \"Hello world!\" --an-int 123");
```
vs.
```cs
var command = new RootCommand
{
new Option("--a-string") { Argument = new Argument() },
new Option("--an-int") { Argument = new Argument() }
};
command.Handler = CommandHandler.Create(
(string aString, int anInt) =>
{
Console.WriteLine($"{aString}");
Console.WriteLine($"{anInt}");
});
await command.InvokeAsync("--an-int 123 --a-string \"Hello world!\" ");
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Apri il tutorial e individua il primo esempio di comando. Sostituisci la configurazione prolissa dell’opzione e dell’handler con la forma Option proposta e un output su una sola riga, quindi verifica che l’esempio dimostri ancora la stessa invocazione del comando e gli stessi valori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- cli, documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 55/100