dotnet / dotnet/command-line-api

Flowing data in System.CommandLine

Offen
#2,162 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

needs discussion
Vorherrschende Sprache
C#
Sterne
3.7k
Forks
428
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

There are a number within the System.CommandLine flow that could potentially supply information used by later steps. From one perspective this is a core part of the process because a return code (exit code) is returned that we anticipate will be the return value of Main.

#2156 discusses what should be returned from the flow. This the broader question about what state/data should be available during execution.

Several things could supply data that could be used by later steps:

  • The calling code (often static void Main(..)
  • Custom parsers
  • Validators (beyond the validation failure info)
  • Pre-actions (non-exclusive actions in #2147)
  • CliAction (the action of the command, previously ICommandHandler)
  • Post-actions if we have them (#2161)

In the old middleware pipeline, closures could be used to stash data between the before/after next step phases, but I do not think there were other ways to share state/data.

Have you ever wished a custom parser could stash some information for use by an action? Any other variation of wanting data to pass between parts of your parser?

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, diesen Issue zusammen mit #2156, #2147 und #2161 zu lesen. Vergleiche anschließend den vorgeschlagenen Ablauf mit der alten Middleware-Pipeline und ihrer auf Closures basierenden Zustandsfreigabe. Als abgeschlossen gilt die Einigung darüber, welche Daten jeder Ausführungsschritt späteren Schritten bereitstellen kann und wie dieser Zustand mit dem Rückgabewert des Befehls zusammenhängt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
cli
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
20/100

Neue Issues direkt in Ihr Postfach

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