-
Notifications
You must be signed in to change notification settings - Fork 9
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
[Discussion] Restructure Command
#26
Comments
@AethanFoot (ping) |
This seems reasonable. Do you mean for this to be used in both places the enums currently are, as my only worry would be the config side in lefthk being overly complicated but internally in lefthk-core this would be fine. |
Maybe we could introduce something like an Adapter-Trait which converts a self-defined-command struct into a lefthk-core-command |
Yeah that seems okay |
alright, then I'd like to take care of this :) |
Done by #27 |
TL;DR
I propose to write every command as a struct instead of putting all commands into an enum. What do you think about @AethanFoot
Motivation
A command has a lot of properties in my opinion. This includes:
- matching a string to themself
- converting themself to a string
- do that what their name says (like reload the daemon if the
Reload
Command was called)- having different arguments
those are all I could find yet and in my opinion this is why we should split the commands up from an
enum
into astruct
for each command.How should it look like
Example:
config/command/mod.rs
config/command/chord.rs
Pros and Cons
Pros
and bigger and the the enum includes the whole logic of all enum-entries
yeah, that's basically it. All functions which affect to all commands (like
searching through them) can be put to
config/command/mod.rs
, the "main"command file.
Cons
here.
This should be, in my opinion:
which would be more typesafety and also makes it easier to change the code since
you don't have to replace the string "Kill" everywhere if you want to rename
this command.
The text was updated successfully, but these errors were encountered: