cmds.projects.CmdCheck: Move to .check.CmdDep
Move CmdCheck to .check.CmdDep, to make room for more checks under the same "check" parent command.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
5a1ef45cc0
commit
f275aa9715
5 changed files with 65 additions and 14 deletions
|
|
@ -1,6 +1,7 @@
|
|||
from argparse import ArgumentParser, Namespace
|
||||
import sys
|
||||
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from ...lib.log import NOTICE, log
|
||||
from .Cmd import Cmd, Parent
|
||||
|
||||
class CmdCheck(Cmd): # export
|
||||
|
|
@ -9,20 +10,14 @@ class CmdCheck(Cmd): # export
|
|||
super().__init__(
|
||||
parent,
|
||||
'check',
|
||||
help = 'Check for circular dependencies between given modules',
|
||||
help = 'Run miscellaneous code and project checks',
|
||||
)
|
||||
self.load_subcommands()
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
super().add_arguments(parser)
|
||||
parser.add_argument('module', nargs = '*', help = 'Modules')
|
||||
parser.add_argument('-f', '--flavour', nargs = '?', default = 'build')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
if self.app.find_circular_deps(args.module, args.flavour):
|
||||
log(NOTICE, f'Found circular dependency in flavour {args.flavour}')
|
||||
exit(1)
|
||||
log(
|
||||
NOTICE,
|
||||
f'No circular dependency found for flavour {args.flavour} in modules:',
|
||||
' '.join(args.module),
|
||||
)
|
||||
async def _run(self, args):
|
||||
# Missing subcommand
|
||||
self.parser.print_help()
|
||||
sys.exit(1)
|
||||
|
|
|
|||
14
src/python/jw/pkg/cmds/projects/check/Cmd.py
Normal file
14
src/python/jw/pkg/cmds/projects/check/Cmd.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from ....CmdBase import CmdBase
|
||||
from ..CmdCheck import CmdCheck as Parent
|
||||
|
||||
class Cmd(CmdBase): # export
|
||||
|
||||
def __init__(self, parent: Parent, name: str, help: str) -> None:
|
||||
super().__init__(parent, name, help)
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
super().add_arguments(parser)
|
||||
28
src/python/jw/pkg/cmds/projects/check/CmdDep.py
Normal file
28
src/python/jw/pkg/cmds/projects/check/CmdDep.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from argparse import ArgumentParser, Namespace
|
||||
|
||||
from ....lib.log import NOTICE, log
|
||||
from .Cmd import Cmd, Parent
|
||||
|
||||
class CmdDep(Cmd): # export
|
||||
|
||||
def __init__(self, parent: Parent) -> None:
|
||||
super().__init__(
|
||||
parent,
|
||||
'deps',
|
||||
help = 'Check for circular dependencies between given modules',
|
||||
)
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
super().add_arguments(parser)
|
||||
parser.add_argument('module', nargs = '*', help = 'Modules')
|
||||
parser.add_argument('-f', '--flavour', nargs = '?', default = 'build')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
if self.app.find_circular_deps(args.module, args.flavour):
|
||||
log(NOTICE, f'Found circular dependency in flavour {args.flavour}')
|
||||
exit(1)
|
||||
log(
|
||||
NOTICE,
|
||||
f'No circular dependency found for flavour {args.flavour} in modules:',
|
||||
' '.join(args.module),
|
||||
)
|
||||
5
src/python/jw/pkg/cmds/projects/check/Makefile
Normal file
5
src/python/jw/pkg/cmds/projects/check/Makefile
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
TOPDIR = ../../../../../../..
|
||||
PY_UPDATE_INIT_PY = false
|
||||
|
||||
include $(TOPDIR)/make/proj.mk
|
||||
include $(JWBDIR)/make/py-mod.mk
|
||||
9
src/python/jw/pkg/cmds/projects/check/__init__.py
Normal file
9
src/python/jw/pkg/cmds/projects/check/__init__.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from ....lib.init import detect_modules
|
||||
|
||||
__all__ = detect_modules(
|
||||
package_name = __name__,
|
||||
package_path = __path__,
|
||||
namespace = globals(),
|
||||
prefix = 'Cmd',
|
||||
skip = {'Cmd'},
|
||||
) # pyright: ignore[reportUnsupportedDunderAll]
|
||||
Loading…
Add table
Add a link
Reference in a new issue