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

Feature Request: Define command REPLs on command types #740

Closed
Hirrolot opened this issue Oct 7, 2022 · 2 comments
Closed

Feature Request: Define command REPLs on command types #740

Hirrolot opened this issue Oct 7, 2022 · 2 comments
Assignees
Labels
feature-accepted Feature Request or Proposal was accepted by maintainers and will be implemented K-feature-request Kind: request for implementing a feature

Comments

@Hirrolot
Copy link
Collaborator

Hirrolot commented Oct 7, 2022

Currently, crate::{commands_repl, commands_repl_with_listener} accept a command type hint as a third parameter. I pondered awhile on how not to require a type hint and came to a stupid solution: just define REPL methods on command types themselves. I.e., we could introduce one more trait with the commands_repl(_with_listener) methods and define it for Cmd: BotCommands, we don't even need to change the macro library.

- teloxide::commands_repl(bot, answer, Command::ty())
+ Command::repl(bot, answer)

Pros

  • More concise syntax -- no need to specify that weird type hint.

Cons

  • Need to deprecate the old command REPLs.
  • Maybe trait methods are more tricky to discover in the API?

Alternatives

  • Leave the design as-is.
@Hirrolot Hirrolot added the K-feature-request Kind: request for implementing a feature label Oct 7, 2022
@WaffleLapkin
Copy link
Member

This proposed API makes a lot more sense than Command::ty, I think we can sacrifice a little discoverability. LGTM.

@WaffleLapkin WaffleLapkin added the feature-accepted Feature Request or Proposal was accepted by maintainers and will be implemented label Oct 10, 2022
@Hirrolot
Copy link
Collaborator Author

Implemented in #746.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-accepted Feature Request or Proposal was accepted by maintainers and will be implemented K-feature-request Kind: request for implementing a feature
Projects
None yet
Development

No branches or pull requests

2 participants