mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 01:25:55 +02:00
cmds.distro.CmdPkg: args.name -> names
Make all pkg commands take a "names" argument (plural) instead of "name", and make it a non-option-argument, to be passed to the subcomand instead. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
8bc22a3a68
commit
ecd077c93d
3 changed files with 9 additions and 4 deletions
|
|
@ -13,7 +13,6 @@ class CmdPkg(Cmd): # export
|
||||||
|
|
||||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||||
super().add_arguments(parser)
|
super().add_arguments(parser)
|
||||||
parser.add_argument('--name', help='Package name')
|
|
||||||
|
|
||||||
async def _run(self, args: Namespace) -> None:
|
async def _run(self, args: Namespace) -> None:
|
||||||
return await self._backend.run(args)
|
return await super()._run(args)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from argparse import Namespace, ArgumentParser
|
||||||
|
|
||||||
from ..Cmd import Cmd as Base
|
from ..Cmd import Cmd as Base
|
||||||
from ..CmdPkg import CmdPkg as Parent
|
from ..CmdPkg import CmdPkg as Parent
|
||||||
|
|
||||||
|
|
@ -10,6 +12,10 @@ class Cmd(Base): # export
|
||||||
def __init__(self, parent: Parent, name: str, help: str) -> None:
|
def __init__(self, parent: Parent, name: str, help: str) -> None:
|
||||||
super().__init__(parent, name, help)
|
super().__init__(parent, name, help)
|
||||||
|
|
||||||
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||||
|
super().add_arguments(parser)
|
||||||
|
parser.add_argument('names', nargs='*', help='Package names')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _backend(self) -> Backend:
|
def _backend(self) -> Backend:
|
||||||
return self.parent._backend
|
return self.parent._backend
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,5 @@ class CmdLs(Cmd): # export
|
||||||
super().add_arguments(parser)
|
super().add_arguments(parser)
|
||||||
|
|
||||||
async def _run(self, args: Namespace) -> None:
|
async def _run(self, args: Namespace) -> None:
|
||||||
files = await self._backend.list_files(args.name)
|
for name in args.names:
|
||||||
print('\n'.join(files))
|
print('\n'.join(await self._backend.files(name)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue