mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
jw.pkg.cmds.Cmd._add_subcommands(): Generic detection
Deduce module search path for the calling module's subcommands directly from the module path of the calling module. That's more generic than the previous detection algorithm, because it recursively works for subcommands of subcommands as well. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
595995e084
commit
a160555596
1 changed files with 4 additions and 6 deletions
|
|
@ -14,9 +14,7 @@ class Cmd(Base): # export
|
|||
super().__init__(parent, name, help)
|
||||
|
||||
def _add_subcommands(self) -> None:
|
||||
self.add_subcommands(
|
||||
LoadTypes(
|
||||
[__name__.rsplit('.', 1)[0] + '.' + self.name],
|
||||
type_name_filter=r'Cmd[^.]'
|
||||
)
|
||||
)
|
||||
# Derive module search path for the calling module's subcommands from
|
||||
# the module path of the calling module itself
|
||||
cmds_module = type(self).__module__.replace('Cmd', '').lower()
|
||||
self.add_subcommands(LoadTypes([cmds_module], type_name_filter=r'Cmd[^.]'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue