-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add support for subcommands in the API #254
Conversation
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports |
Test results 3 files 3 suites 51s ⏱️ Results for commit 7fbd015. ♻️ This comment has been updated with latest results. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #254 +/- ##
==========================================
+ Coverage 98.99% 99.04% +0.05%
==========================================
Files 50 50
Lines 6739 6747 +8
==========================================
+ Hits 6671 6682 +11
+ Misses 68 65 -3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine start, now you "just" need to update the tests :)
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's a fine attempt, I feel like this just complicates future maintenance.
Specifically, I'm not comfortable with having to explicitly add new methods to a an extra config tuple, located potentially far away from the implementation itself, to mark them as special. Marking these functions using a decorator would be nicer.
However, at this point, I might suggest two different approaches:
-
Add more magic to the dispatcher code so it finds valid commands from method names, automatically understanding
do_x_y()
as an implementation of the commandX Y
whiledo_x()
is a different command. -
Or, toss the magic stuff I wrote earlier and switch to a scheme involving explicit routing of commands using decorators. Think similarly to flask routes, e.g.
@route("PM") def do_pm(self): ... @route("PM ADD") def do_pm_add(self, arg1, arg2): ...
I would pair on something like this, if desirable :)
#247 is used instead |
Fixes #255
Suggestion for supporting subcommands. Adds a constant tuple where commands that support subcommands can be added (for us this will contain
pm
). If a command is registered in that tuple, the dispatcher will attempt to add the first argument to the command and look for functions matching this. If main command ispm
and subcommand isdetails
then it will look fordo_pm_details
I imagine the
Zino1ServerProtocol
subclass would registerpm
as a subcommand by overriding the tupleThis is preliminary work for implementing the planned maintenance API commands, so i dont think this needs to be part of the changelog. The commands themselves will be, however