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

Implement the CommandRepl trait #746

Merged
merged 5 commits into from Oct 29, 2022
Merged

Implement the CommandRepl trait #746

merged 5 commits into from Oct 29, 2022

Conversation

Hirrolot
Copy link
Collaborator

Resolves #740.

I think that after removing the deprecated commands_repl_(with_listener) functions, we can merge all REPLs into a single *.rs file, but for now, let's leave it as-is.

@Hirrolot
Copy link
Collaborator Author

@WaffleLapkin, I think it's ready for review.

#[doc = include_str!("caution.md")]
///
#[cfg(feature = "ctrlc_handler")]
pub trait CommandRepl {
Copy link
Member

Choose a reason for hiding this comment

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

I don't really see the reason to make a separate trait. Can't we just add methods to BotCommands?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could, but a separate trait is more for a separation of concerns. What it means practically is that the utils::command module doesn't depend on dispatching, which is good for compilation time. Also, CommandRepl can be founded in the same module as message REPLs, since it's a similar thing.

Copy link
Member

Choose a reason for hiding this comment

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

which is good for compilation time

I don't think that inter crate dependency matters for compilation time that much.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That single change probably wouldn't matter, but as we overload our modules with redundant dependencies, in conglomeration, it probably would. E.g., when you change X upon which Y depends, then the compiler has to recompile both modules.

@Hirrolot
Copy link
Collaborator Author

Hirrolot commented Oct 22, 2022

I do still insist on a separate trait since it provides better system decomposition. It also follows the principle of least astonishment, since users could find it in the same place as other REPLs and not scattered throughout the whole library.

@WaffleLapkin
Copy link
Member

Maybe a CommandExt or CommandReplExt would be a better name for the trait? Because "Repl" is not a property of the type, but just the extension method group

@Hirrolot Hirrolot merged commit cb2298d into dev Oct 29, 2022
@Hirrolot Hirrolot deleted the command-repl branch October 29, 2022 09:34
WaffleLapkin pushed a commit that referenced this pull request Nov 1, 2022
Implement the `CommandRepl` trait

Former-commit-id: cb2298d
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