Abort on ambiguous subcommand names#629
Closed
dcantah wants to merge 1 commit into
Closed
Conversation
4 tasks
rauhul
reviewed
Apr 4, 2024
Currently it's possible to have two commands with the same _commandName by mixing a combination of the automatic command name generation based on the type name, and explicit use of `CommandConfiguration`'s commandName parameter. For example, if we edit the math examples `Add` command to have a commandName of "multiply" this is allowed currently: ``` ./.build/debug/math multiply 2 3 5 ``` The behavior today is whatever subcommand is registered in the tree first is what will resolve for that command. So, `Multiply` in this example is permanently shadowed. This change just makes sure there's no occurence of this happening in any level of the tree of potential subcommands, and if so we'll abort early.
1d3e481 to
241162e
Compare
Contributor
Author
|
@swift-ci please test |
Contributor
Author
|
Gentle ping on this 😆. I'll start with this change as #627 can feed from it. |
Contributor
Author
|
Let me draft this until I have time to fix up the way we validate this |
Contributor
Author
|
Closing this as adding some validations here seems very tricky, if we do want this I'm glad to brainstorm with someone |
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.
Currently it's possible to have two commands with the same _commandName by mixing a combination of the automatic command name generation based on the type name, and explicit use of
CommandConfiguration's commandName parameter. For example, if we edit the math examplesAddcommand to have a commandName of "multiply" this is allowed currently:The behavior today is whatever subcommand is registered in the tree first is what will resolve for that command. So,
Multiplyin this example is permanently shadowed.This change just makes sure there's no occurence of this happening in any level of the tree of potential subcommands, and if so we'll abort early.
Note
I can't imagine this happens too often, but the detection logic will also be useful to verify clashing aliases+subcommands for this change as well #627.
Checklist