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:
Jan Lindemann 2026-06-01 09:18:34 +02:00
commit f275aa9715
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
5 changed files with 65 additions and 14 deletions

View file

@ -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)

View 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)

View 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),
)

View file

@ -0,0 +1,5 @@
TOPDIR = ../../../../../../..
PY_UPDATE_INIT_PY = false
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-mod.mk

View 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]