Skip to content

Handle command name/alias collision properly #371

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

Open
daxian-dbw opened this issue Apr 18, 2025 · 0 comments
Open

Handle command name/alias collision properly #371

daxian-dbw opened this issue Apr 18, 2025 · 0 comments
Labels
Issue-Enhancement The issue is a feature or idea

Comments

@daxian-dbw
Copy link
Member

Summary of the new feature / enhancement

Command names and aliases may collide. Today, we don't handle it, so an exception will be thrown when collision happens. We should handle the name/alias collision gracefully.

// The 'command.Name' is included in the 'command.Aliases' collection.
// TODO: need to think about how to handle command names/aliases collision.
// We don't handle collision today -- it will throw when collision happens.
foreach (string alias in command.Aliases)
{
_commands.Add(alias, command);
}

// The 'command.Name' is included in the 'command.Aliases' collection.
// TODO: need to update accordingly when we handle command names/aliases collision.
foreach (string alias in command.Aliases)
{
_commands.Remove(alias);
}

Proposed technical implementation details (optional)

We load commands from an agent when switching to the agent and unload its commands when switching away from it. So, at a given time, only commands from one agent will co-exist with the core commands. Therefore, we shouldn't allow a name/alias to overwrite an existing one and hence we should throw a good error when collision happens.

@daxian-dbw daxian-dbw added the Issue-Enhancement The issue is a feature or idea label Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement The issue is a feature or idea
Projects
None yet
Development

No branches or pull requests

1 participant