dotnet / dotnet/command-line-api
Flowing data in System.CommandLine
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
Assessment
This issue has not been assessed yet.