diff --git a/src/python/jw/pkg/cmds/distro/CmdDelete.py b/src/python/jw/pkg/cmds/distro/CmdDelete.py new file mode 100644 index 00000000..c4b5c12a --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/CmdDelete.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from argparse import Namespace, ArgumentParser + +from .Cmd import Cmd +from ..CmdDistro import CmdDistro + +class CmdDelete(Cmd): # export + + def __init__(self, parent: CmdDistro) -> None: + super().__init__(parent, 'delete', help="Delete packages by name") + + def add_arguments(self, parser: ArgumentParser) -> None: + super().add_arguments(parser) + parser.add_argument("packages", nargs="*", help="Names of packages to be deleted") + + async def _run(self, args: Namespace) -> None: + return await self._backend.run(args) diff --git a/src/python/jw/pkg/cmds/distro/backend/BeDelete.py b/src/python/jw/pkg/cmds/distro/backend/BeDelete.py new file mode 100644 index 00000000..46cc551e --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/BeDelete.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +import abc +from argparse import Namespace + +from .Backend import Backend as Base +from ..CmdDelete import CmdDelete as Parent + +class BeDelete(Base): + + def __init__(self, parent: Parent): + super().__init__(parent) + + @abc.abstractmethod + async def run(self, args: Namespace) -> None: + pass diff --git a/src/python/jw/pkg/cmds/distro/backend/suse/Delete.py b/src/python/jw/pkg/cmds/distro/backend/suse/Delete.py new file mode 100644 index 00000000..e6d67fc0 --- /dev/null +++ b/src/python/jw/pkg/cmds/distro/backend/suse/Delete.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +from argparse import Namespace + +from ...Cmd import Cmd +from ..BeDelete import BeDelete as Base + +class Delete(Base): + + def __init__(self, parent: Cmd): + super().__init__(parent) + + async def run(self, args: Namespace): + return await self.util.rpm('-e', *args.packages, sudo=True)