mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 17:45:55 +02:00
cmds.secrets.CmdXX: Add option --all
Support option --all to jw-pkg.py secrets list-compilation-output and list-secrets (CmdListCompilationOutput & CmdSecrets). This allows them to also report non-existent files. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
699980c32e
commit
1ffac7b365
3 changed files with 26 additions and 6 deletions
|
|
@ -206,11 +206,23 @@ class Cmd(Base): # export
|
||||||
async def _list_template_files(self, packages: Iterable[str]) -> list[str]:
|
async def _list_template_files(self, packages: Iterable[str]) -> list[str]:
|
||||||
return await self._match_files(packages, pattern=r'.*\.jw-tmpl$')
|
return await self._match_files(packages, pattern=r'.*\.jw-tmpl$')
|
||||||
|
|
||||||
async def _list_secret_paths(self, packages: Iterable[str]) -> list[str]:
|
async def _list_secret_paths(self, packages: Iterable[str], ignore_missing: bool=False) -> list[str]:
|
||||||
return [str(Path(f).with_suffix(".jw-secret")) for f in await self._list_template_files(packages)]
|
ret = []
|
||||||
|
for tmpl in await self._list_template_files(packages):
|
||||||
|
path = str(Path(tmpl).with_suffix(".jw-secret"))
|
||||||
|
if ignore_missing and not os.path.exists(path):
|
||||||
|
continue
|
||||||
|
ret.append(path)
|
||||||
|
return ret
|
||||||
|
|
||||||
async def _list_compilation_targets(self, packages: Iterable[str]) -> list[str]:
|
async def _list_compilation_targets(self, packages: Iterable[str], ignore_missing: bool=False) -> list[str]:
|
||||||
return [f.removesuffix('.jw-tmpl') for f in await self._list_template_files(packages)]
|
ret = []
|
||||||
|
for tmpl in await self._list_template_files(packages):
|
||||||
|
path = tmpl.removesuffix('.jw-tmpl')
|
||||||
|
if ignore_missing and not os.path.exists(path):
|
||||||
|
continue
|
||||||
|
ret.append(path)
|
||||||
|
return ret
|
||||||
|
|
||||||
async def _remove_compilation_targets(self, packages: Iterable[str]) -> list[str]:
|
async def _remove_compilation_targets(self, packages: Iterable[str]) -> list[str]:
|
||||||
for path in await self._list_compilation_targets(packages):
|
for path in await self._list_compilation_targets(packages):
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,9 @@ class CmdListCompilationOutput(Cmd): # export
|
||||||
def __init__(self, parent: CmdSecrets) -> None:
|
def __init__(self, parent: CmdSecrets) -> None:
|
||||||
super().__init__(parent, 'list-compilation-output', help="List package compilation output files")
|
super().__init__(parent, 'list-compilation-output', help="List package compilation output files")
|
||||||
|
|
||||||
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||||
|
super().add_arguments(parser)
|
||||||
|
parser.add_argument("--all", action='store_true', default=False, help="Show all output targets, including non-existent files")
|
||||||
|
|
||||||
async def _run(self, args: Namespace) -> None:
|
async def _run(self, args: Namespace) -> None:
|
||||||
await _remove_compilation_targets(args.packages)
|
print('\n'.join(await self._list_compilation_targets(args.packages, ignore_missing=(not args.all))))
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,9 @@ class CmdListSecrets(Cmd): # export
|
||||||
def __init__(self, parent: CmdSecrets) -> None:
|
def __init__(self, parent: CmdSecrets) -> None:
|
||||||
super().__init__(parent, 'list-secrets', help="List package secret files")
|
super().__init__(parent, 'list-secrets', help="List package secret files")
|
||||||
|
|
||||||
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||||
|
super().add_arguments(parser)
|
||||||
|
parser.add_argument("--all", action='store_true', default=False, help="Show all secret paths, including non-existent files")
|
||||||
|
|
||||||
async def _run(self, args: Namespace) -> None:
|
async def _run(self, args: Namespace) -> None:
|
||||||
print('\n'.join(await self._list_secret_paths(args.packages)))
|
print('\n'.join(await self._list_secret_paths(args.packages, ignore_missing=(not args.all))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue