CmdBase / cmds.projects.Cmd: Add modules
Lots of sub- and sub-subcommands are derived from the base class of the invoking command, notably below cmds.projects. That provides some properties shared across the ancestor hierarchy of a command, but is semantically unsound. Introduce jw.pkg.BaseCmd class as a place to provide basic helpers shared across all commands used in a jw.pkg.App's context. Also add cmds.projects.Cmd to be used by other commands in cmds.projects in later commits. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
13ec34cc57
commit
8697695697
2 changed files with 27 additions and 0 deletions
13
src/python/jw/pkg/CmdBase.py
Normal file
13
src/python/jw/pkg/CmdBase.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
from .App import App
|
||||
from .lib.Cmd import Cmd as Base
|
||||
|
||||
class CmdBase(Base):
|
||||
|
||||
@property
|
||||
def app(self) -> App:
|
||||
ret = super().app
|
||||
if not isinstance(ret, App):
|
||||
raise TypeError(
|
||||
f'Expected {self.__class__.__name__}, got {type(ret).__name__}'
|
||||
)
|
||||
return ret
|
||||
Loading…
Reference in a new issue