Skip to content
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

Abort on ambiguous subcommand names #629

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dcantah
Copy link
Member

@dcantah dcantah commented 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.

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

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@dcantah dcantah mentioned this pull request Apr 4, 2024
4 tasks
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.
@dcantah
Copy link
Member Author

dcantah commented Apr 11, 2024

@swift-ci please test

@dcantah
Copy link
Member Author

dcantah commented Apr 22, 2024

Gentle ping on this 😆. I'll start with this change as #627 can feed from it.

@dcantah
Copy link
Member Author

dcantah commented May 2, 2024

Let me draft this until I have time to fix up the way we validate this

@dcantah dcantah marked this pull request as draft May 2, 2024 22:02
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

Successfully merging this pull request may close these issues.

None yet

2 participants