8000 Replace | with or when searching for Argument value by tdashworth · Pull Request #1053 · dotnet/command-line-api · GitHub
[go: up one dir, main page]

Skip to content

Replace | with or when searching for Argument value #1053

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

Merged
merged 4 commits into from
Oct 29, 2020

Conversation

tdashworth
Copy link
Contributor

This allows the CommandHandler to be registered with fileOrString for an Argument named File|String.

#1051

This allows the CommandHandler to be registered with `fileOrString` for an Argument named `File|String`.

dotnet#1051
@tdashworth tdashworth changed the title Replace | with or when searching for value Replace | with or when searching for Argument value Oct 3, 2020
@jonsequitur
Copy link
Contributor

This is a pretty cool idea. I worry that string-based conventions like this can be a bit hard to discover, but in this case, not knowing about it wouldn't get in the way. Not knowing about the name-based matching in general, on the other hand, has been the most common pitfall in our design, thus #1012.

Adding @Keboo and @KathleenDollard for their thoughts.

@Keboo
Copy link
Member
Keboo commented Oct 4, 2020

No real objection from me but it would be nice to see some tests on this.

@tdashworth
Copy link
Contributor Author

@Keboo Will look to add tests in the coming days 😀

@dnfadmin
Copy link
dnfadmin commented Oct 4, 2020

CLA assistant check
All CLA requirements met.

@tdashworth
Copy link
Contributor Author

Hey - any chance of a review now I've added some tests? Thanks

@@ -36,7 +36,7 @@ public static class CommandResultExtensions
{
foreach (var argument in commandResult.Command.Arguments)
{
if (valueName.IsMatch(argument.Name))
if (valueName.IsMatch(argument.Name) || valueName.IsMatch(argument.Name.Replace("|","or")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should maybe be moved to the IsMatch method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I had considered not doing to before to allow the or with and without the replacement. After realising that a | is invalid in a parameter name - this shouldn't cause any breaking changes.

@tdashworth
Copy link
Contributor Author

Can this be reviewed again, please?

@jonsequitur jonsequitur merged commit dc3011c into dotnet:main Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development 3B2C

Successfully merging this pull request may close these issues.

4 participants
0