Remove Legacy `--` behavior and use of UnparsedTokens
See original GitHub issueIs your feature request related to a problem? Please describe.
As part of cleaning up the CLI, we should remove our use of the LegacyDoubleDashHandling logic in System.CommandLine, and instead be explicit about argument forwarding as described here. We are the main user of LegacyDoubleDashHandling, and System.CommandLine wants to remove that API entirely (see https://github.com/dotnet/command-line-api/issues/1653).
Describe the solution you’d like
In places where we use the double-dash behavior and UnparsedTokens to forward arguments along, we should instead create an explicit string[]
Argument and forward the value of that argument along. This also leads to more useful help displays for the user.
Areas of specific interest/concern
Direct use of UnparsedTokens
These are straightforward, and in the ‘new world’ would simply be removed, as the UnmatchedTokens
+ a new string[]
argument should cover all use cases
ParseResult.GetArguments()/ParseResult.GetSubArguments()
Definition is here. The GetArguments()
extension method is commonly used to grab all of the tokens in a command and delegate them to some non-bundled command. Adding a string[]
argument may make this easier/not necessary to do for some forwarding applications.
GetSubArguments()
is the more concerning one to me - it actually modifies the token stream. This may not be necessary after the change to the --
handling, but the custom logic about removing the dotnet
command if it is prepended, as well as the 'top-level` command, may still be required.
Direct use of --
in command processors
Specific commands/scenarios to verify
- dotnet build
- dotnet msbuild
- dotnet test
- dotnet vstest
- dotnet run
- dotnet publish
- any nuget command
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top GitHub Comments
@marcpopMSFT I think you can close this issue. PR fixed it. @baronfel I’ll create a separate issue for custom parsers, so we won’t forget about it.
Yes, of course! The problem with removing
UnparsedToken
is that it’s currently being populated by theLegacyDoubleDashHandling
setting we have configured. So if we want to remove use ofUnparsedToken
we have to change the value of this setting, and that means that we have to fix the semantics of all of these call-sites. It’s definitely a puzzle 😃