RegexCommand's now get matched last
parent
78290554bd
commit
46d8d4322e
|
@ -6,7 +6,7 @@ from __future__ import annotations
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
|
|
||||||
# Own imports
|
# Own imports
|
||||||
from .decorators import Command, Daemon, Default
|
from .decorators import Command, Daemon, Default, RegexCommand
|
||||||
|
|
||||||
# Typing imports
|
# Typing imports
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
@ -33,8 +33,11 @@ class ModuleMeta:
|
||||||
@cached_property
|
@cached_property
|
||||||
def commands(self) -> List[Command]:
|
def commands(self) -> List[Command]:
|
||||||
# This also matches RegexCommand objects
|
# This also matches RegexCommand objects
|
||||||
# TODO: sort this to put RegexCommand's at the back
|
# The sort puts all the RegexCommand objects at the back, making them
|
||||||
return self._filter_attrs(lambda val: isinstance(val, Command))
|
# be matched last
|
||||||
|
|
||||||
|
return sorted(self._filter_attrs(lambda val: isinstance(val, Command)),
|
||||||
|
key=lambda x: isinstance(x, RegexCommand))
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def daemons(self) -> List[Daemon]:
|
def daemons(self) -> List[Daemon]:
|
||||||
|
|
Reference in New Issue