Show help output when there are unmatched tokens passed to update-dependencies CLI#6402
Merged
Conversation
mthalman
reviewed
Apr 29, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the update-dependencies CLI to show the help output when unmatched tokens are provided, and then throws an exception containing the extra tokens.
- Introduces a hostBuilderFactory lambda to check for unmatched tokens.
- Uses HelpBuilder to display the help message before throwing an InvalidOperationException.
Co-authored-by: Matt Thalman <mthalman@microsoft.com>
mthalman
approved these changes
Apr 30, 2025
This was referenced May 2, 2025
lbussell
added a commit
to lbussell/dotnet-docker
that referenced
this pull request
May 9, 2025
…endencies CLI (dotnet#6402) Co-authored-by: Matt Thalman <mthalman@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6394
System.Commandline.Hostingforcibly setsyourCommand.TreatUnmatchedTokensAsErrors = falseand also overrides the command's action, so we can't fix this behavior by either of those means.However, unmatched tokens are passed to the
hostBuilderFactory, which allows you to configure additional hosting options based on those extra tokens. Since we don't need those extra arguments, we can use that opportunity to print the help output and throw an exception.https://github.com/dotnet/command-line-api/blob/a91bcf488ba7d0112b2637b505f8de32aded6825/src/System.CommandLine.Hosting/HostingAction.cs#L26-L27