fix #2760 - provide parser override via new Argument.CaptureRemainingTokens property#2783
fix #2760 - provide parser override via new Argument.CaptureRemainingTokens property#2783jonsequitur wants to merge 4 commits intodotnet:mainfrom
Argument.CaptureRemainingTokens property#2783Conversation
That is what I would expect. |
I imagine a custom parser could very well transform this token sequence to a non-enumerable type. |
Argument.CaptureRemainingTokens property
jeffhandley
left a comment
There was a problem hiding this comment.
Since this is an implicit --, I started entertaining if we could take a different approach where we encapsulate the current double-dash implementation in a special-purpose Argument<string[]> that always captures all remaining tokens. That argument could be explicitly added to the CLI definition (as the last argument) to make the -- implicit, and if it's not already added to the CLI then we would add it with the "--" name.
An approach like that could prevent us from having 2 different mechanism for capturing the remaining tokens, and we could disallow that special argument from having a max capacity that can get filled up.
BUT after some feasibility research, I don't think it would come in very cleanly for a few reasons:
- Trying to encapsulate
--as an argument or option would affect tokenizing logic and how the remaining tokens are treated/exposed - It would be challenging to make that change in a backwards-compatible manner for the existing
UnmatchedTokens - Would it be an Option or an Argument? Kind of both. Kind of neither.
I'm not convinced on the CaptureRemainingTokens name either, and I'm anxious about the complexity of filling to capacity and needing to spill over and that being potentially unintuitive. But this does plug in pretty cleanly overall.
I'll come back to this PR after thinking about it some more.
|
Yeah, the name |
We considered this design when we were changing the way It is appealing as a way to reduce concept count though. |
This fixes #2760 by adding a new property currently named
Argument.CaptureRemainingTokens.I'm not sure this is the right name but the behavior is that this argument will capture everything following it regardless of whether it happens to match some well-known symbol. A few notes on this implementation:
Greedymight be more accurate. Can we assume this term is intuitive enough?--token has no special meaning when captured by anArgumentwith this property set totrue. It gets captured as one of the tokens.@baronfel @tmds Thoughts?