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

Panic on duplicate command names #317

merged 2 commits into from Jul 17, 2022


Copy link

Closes #300

Adds supports for validating if command names are not duplicated within a single node's children.
Panics if they are duplicated.

This is a breaking change in case a project has duplicated command names.
Positional arguments are not affected and can have duplicated names.

Copy link

LGTM just a minor linter issue - feel free to disable gocyclo in .golangci.yml

Copy link
Contributor Author

@alecthomas I resolved the gocyclo error. Once the workflow runs, this shall be ready for merging.

On a side note - I wanted to add the same check for aliases vs. names but there's a test which fails afterwards.
I'm not sure if it's expected behavior. In this case the Cmd does not run, but OtherCmd is invoked.
My understanding is aliases trigger the same command (Cmd in this case) just with a different name.

In this example it would not be clear which command to run:

var cli struct {
  CmdA Command `cmd aliases:"my-cmd"`
  CmdB Command `cmd aliases:"my-cmd"`

I'm happy to submit a PR for aliases check as well if you agree.

Copy link

Mmm good point, duplicate aliases shouldn't be allowed either. A PR would be great!

@alecthomas alecthomas merged commit f9bc630 into alecthomas:master Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Kong allows multiple sub-commands to have the same name
2 participants