-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flowing data in System.CommandLine #2162
Comments
I have wanted a way to have interspersed options and arguments such that each option modifies, but does not entirely override, the handling of the subsequent arguments. For example,
I had a feature like that in one app, but it was not essential, so I was able to omit it when porting to System.CommandLine. Somewhat similarly, in POSIX c99, the placement of With the current System.CommandLine API, I think this could be implemented in an application by enumerating ParseResult.Tokens and comparing them to SymbolResult.Tokens of the options and the arguments, like I do for redaction in #1795 (comment). Making CliToken.Symbol public as in #2080 would simplify that. |
I had opened an issue for supporting this through |
I believe the non-exclusive CLI actions design could accommodate this, given a context object that they can each interact with in turn. |
@jonsequitur that would require the CliAction to be called for each occurrence of the option. IIRC the option argument parser is called only once per command line even if the option is repeated, so I'm surprised if the CliAction is called differently. |
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:
static void Main(..)
CliAction
to be non-exclusive #2147)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?
The text was updated successfully, but these errors were encountered: