jw.pkg.cmds.distro.CmdDelete: Add command

Add command to delete named packages, along with an implementation
for OpenSUSE.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-17 15:32:07 +01:00
commit 4153fa7c05
3 changed files with 48 additions and 0 deletions

View file

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

View file

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

View file

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