cmds.distro.CmdXxx: Rename to cmds.pkg.CmdXxx
With the exception of the "info" subcommand, nearly all of distro's subcommands deal with package managing, so push them into their own command category.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
c19111e5b6
commit
5830984bfc
17 changed files with 65 additions and 41 deletions
|
|
@ -8,7 +8,7 @@ from .Cmd import Cmd as CmdBase
|
|||
class CmdDistro(CmdBase): # export
|
||||
|
||||
def __init__(self, parent: App) -> None:
|
||||
super().__init__(parent, 'distro', help="System package manager wrapper")
|
||||
super().__init__(parent, 'distro', help="Miscellaneous platform-related comamnds")
|
||||
self._add_subcommands()
|
||||
|
||||
def add_arguments(self, p: ArgumentParser) -> None:
|
||||
|
|
|
|||
15
src/python/jw/pkg/cmds/CmdPkg.py
Normal file
15
src/python/jw/pkg/cmds/CmdPkg.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from ..App import App
|
||||
from .Cmd import Cmd as CmdBase
|
||||
|
||||
class CmdPkg(CmdBase): # export
|
||||
|
||||
def __init__(self, parent: App) -> None:
|
||||
super().__init__(parent, 'pkg', help="System package manager wrapper")
|
||||
self._add_subcommands()
|
||||
|
||||
def add_arguments(self, p: ArgumentParser) -> None:
|
||||
super().add_arguments(p)
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from .Cmd import Cmd
|
||||
from ..CmdDistro import CmdDistro
|
||||
|
||||
class CmdPkg(Cmd): # export
|
||||
|
||||
def __init__(self, parent: CmdDistro) -> None:
|
||||
super().__init__(parent, 'pkg', help="Show package information")
|
||||
self._add_subcommands()
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
super().add_arguments(parser)
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
return await super()._run(args)
|
||||
16
src/python/jw/pkg/cmds/pkg/Cmd.py
Normal file
16
src/python/jw/pkg/cmds/pkg/Cmd.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...lib.Distro import Distro
|
||||
from ..CmdPkg import CmdPkg
|
||||
|
||||
from ..Cmd import Cmd as Base
|
||||
|
||||
class Cmd(Base): # export
|
||||
|
||||
def __init__(self, parent: CmdPkg, name: str, help: str) -> None:
|
||||
super().__init__(parent, name, help)
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from .Cmd import Cmd
|
||||
from ..CmdDistro import CmdDistro
|
||||
from ..CmdPkg import CmdPkg
|
||||
|
||||
class CmdDelete(Cmd): # export
|
||||
|
||||
def __init__(self, parent: CmdDistro) -> None:
|
||||
def __init__(self, parent: CmdPkg) -> None:
|
||||
super().__init__(parent, 'delete', help="Delete packages by name")
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from .Cmd import Cmd
|
||||
from ..CmdDistro import CmdDistro
|
||||
from ..CmdPkg import CmdPkg
|
||||
|
||||
class CmdDup(Cmd): # export
|
||||
|
||||
def __init__(self, parent: CmdDistro) -> None:
|
||||
def __init__(self, parent: CmdPkg) -> None:
|
||||
super().__init__(parent, 'dup', help="Upgrade distribution")
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from .Cmd import Cmd
|
||||
from ..CmdDistro import CmdDistro
|
||||
from ..CmdPkg import CmdPkg
|
||||
|
||||
class CmdInstall(Cmd): # export
|
||||
|
||||
def __init__(self, parent: CmdDistro) -> None:
|
||||
def __init__(self, parent: CmdPkg) -> None:
|
||||
super().__init__(parent, 'install', help="Install the distribution's notion of available packages")
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from .Cmd import Cmd
|
||||
from .NamedPkgsCmd import NamedPkgsCmd as Base
|
||||
from ..CmdPkg import CmdPkg
|
||||
|
||||
class CmdLs(Cmd): # export
|
||||
class CmdLs(Base): # export
|
||||
|
||||
def __init__(self, parent: CmdPkg) -> None:
|
||||
super().__init__(parent, 'ls', help="List package contents")
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from .Cmd import Cmd
|
||||
from .NamedPkgsCmd import NamedPkgsCmd as Base
|
||||
from ..CmdPkg import CmdPkg
|
||||
|
||||
class CmdMeta(Cmd): # export
|
||||
class CmdMeta(Base): # export
|
||||
|
||||
def __init__(self, parent: CmdPkg) -> None:
|
||||
super().__init__(parent, 'meta', help="List package metadata")
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from .Cmd import Cmd
|
||||
from ..CmdDistro import CmdDistro
|
||||
from ..CmdPkg import CmdPkg
|
||||
|
||||
class CmdRebootRequired(Cmd): # export
|
||||
|
||||
def __init__(self, parent: CmdDistro) -> None:
|
||||
def __init__(self, parent: CmdPkg) -> None:
|
||||
super().__init__(parent, 'reboot-required', help="Check whether the machine needs rebooting")
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from .Cmd import Cmd
|
||||
from ..CmdDistro import CmdDistro
|
||||
from ..CmdPkg import CmdPkg
|
||||
|
||||
class CmdRefresh(Cmd): # export
|
||||
|
||||
def __init__(self, parent: CmdDistro) -> None:
|
||||
def __init__(self, parent: CmdPkg) -> None:
|
||||
super().__init__(parent, 'refresh', help="Refresh the distribution's notion of available packages")
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
|
|
@ -5,12 +5,12 @@ import re
|
|||
|
||||
from ...lib.Package import Package
|
||||
from ...lib.PackageFilter import PackageFilterString
|
||||
from ..CmdDistro import CmdDistro
|
||||
from ..CmdPkg import CmdPkg
|
||||
from .Cmd import Cmd
|
||||
|
||||
class CmdSelect(Cmd): # export
|
||||
|
||||
def __init__(self, parent: CmdDistro) -> None:
|
||||
def __init__(self, parent: CmdPkg) -> None:
|
||||
super().__init__(parent, 'select', help="Select packages by filter")
|
||||
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
TOPDIR = ../../../../../../..
|
||||
#PY_UPDATE_INIT_PY = false
|
||||
TOPDIR = ../../../../../..
|
||||
PY_UPDATE_INIT_PY = false
|
||||
|
||||
include $(TOPDIR)/make/proj.mk
|
||||
include $(JWBDIR)/make/py-mod.mk
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from ..Cmd import Cmd as Base
|
||||
from .Cmd import Cmd as Base
|
||||
from ..CmdPkg import CmdPkg as Parent
|
||||
|
||||
class Cmd(Base): # export
|
||||
class NamedPkgsCmd(Base): # export
|
||||
|
||||
def __init__(self, parent: Parent, name: str, help: str) -> None:
|
||||
super().__init__(parent, name, help)
|
||||
11
src/python/jw/pkg/cmds/pkg/__init__.py
Normal file
11
src/python/jw/pkg/cmds/pkg/__init__.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import importlib, pkgutil
|
||||
|
||||
__all__ = []
|
||||
|
||||
for finder, module_name, ispkg in pkgutil.iter_modules(__path__):
|
||||
if not module_name.startswith("Cmd"):
|
||||
continue
|
||||
module = importlib.import_module(f".{module_name}", __name__)
|
||||
cls = getattr(module, module_name)
|
||||
globals()[module_name] = cls
|
||||
__all__.append(module_name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue