diff --git a/frank/module/meta.py b/frank/module/meta.py index c78aac6..c488b7e 100644 --- a/frank/module/meta.py +++ b/frank/module/meta.py @@ -6,7 +6,7 @@ from __future__ import annotations from functools import cached_property # Own imports -from .decorators import Command, Daemon, Default +from .decorators import Command, Daemon, Default, RegexCommand # Typing imports from typing import TYPE_CHECKING @@ -33,8 +33,11 @@ class ModuleMeta: @cached_property def commands(self) -> List[Command]: # This also matches RegexCommand objects - # TODO: sort this to put RegexCommand's at the back - return self._filter_attrs(lambda val: isinstance(val, Command)) + # The sort puts all the RegexCommand objects at the back, making them + # be matched last + + return sorted(self._filter_attrs(lambda val: isinstance(val, Command)), + key=lambda x: isinstance(x, RegexCommand)) @cached_property def daemons(self) -> List[Daemon]: