dotnet / dotnet/command-line-api
Consider using Option<T> in tutorial
- Vorherrschende Sprache
- C#
- Sterne
- 3.7k
- Forks
- 428
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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!\" ");
Beitragsleitfaden
Rechercherichtung
Öffnen Sie das Tutorial und suchen Sie das erste Befehlsbeispiel. Ersetzen Sie die ausführliche Einrichtung von Option und Handler durch die vorgeschlagene Option-Form und eine einzeilige Ausgabe. Überprüfen Sie anschließend, dass das Beispiel weiterhin denselben Befehlsaufruf und dieselben Werte demonstriert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- cli, documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 55/100