Skip to content

Refactor command to make is shorter

DISSOUBRAY Nathan requested to merge refactor_command into master

Description

I noticed that most functions of commands had a similar shape, so I made it more compact by making calls to the same function for all the commands, with different parameters

List of changes

  • Factorize the match.receiver by writing a new async function
  • Write code to convert to serialize (which was the main thing that didn't allow the previous point)
  • Write a macro to further factorize the code that was left in functions

Additional notes

I think that the first two changes should be kept as it's pretty clear was it is done and it organizes the code better. For the macro part, while it indeed shortens the code, macros are generally a bit harder to read and maintain, so we may want to keep code very similar between functions.

The reason for using a macro is that the number of arguments for each variant of DragoonCommand is not always the same, so factorizing means writing a function with a variable number of parameters (thus the macro).

I think it would be interesting to run this first after building it, to check that everything works as intended (since we don't have tests yet).

Merge request reports