diff --git a/src/python/jw/pkg/cmds/secrets/Cmd.py b/src/python/jw/pkg/cmds/secrets/Cmd.py index e46865a9..e6fddc83 100644 --- a/src/python/jw/pkg/cmds/secrets/Cmd.py +++ b/src/python/jw/pkg/cmds/secrets/Cmd.py @@ -206,11 +206,23 @@ class Cmd(Base): # export async def _list_template_files(self, packages: Iterable[str]) -> list[str]: return await self._match_files(packages, pattern=r'.*\.jw-tmpl$') - async def _list_secret_paths(self, packages: Iterable[str]) -> list[str]: - return [str(Path(f).with_suffix(".jw-secret")) for f in await self._list_template_files(packages)] + async def _list_secret_paths(self, packages: Iterable[str], ignore_missing: bool=False) -> list[str]: + 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]: - return [f.removesuffix('.jw-tmpl') for f in await self._list_template_files(packages)] + async def _list_compilation_targets(self, packages: Iterable[str], ignore_missing: bool=False) -> list[str]: + 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]: for path in await self._list_compilation_targets(packages): diff --git a/src/python/jw/pkg/cmds/secrets/CmdListCompilationOutput.py b/src/python/jw/pkg/cmds/secrets/CmdListCompilationOutput.py index 08baecf9..7f976bcd 100644 --- a/src/python/jw/pkg/cmds/secrets/CmdListCompilationOutput.py +++ b/src/python/jw/pkg/cmds/secrets/CmdListCompilationOutput.py @@ -14,5 +14,9 @@ class CmdListCompilationOutput(Cmd): # export def __init__(self, parent: CmdSecrets) -> None: 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: - await _remove_compilation_targets(args.packages) + print('\n'.join(await self._list_compilation_targets(args.packages, ignore_missing=(not args.all)))) diff --git a/src/python/jw/pkg/cmds/secrets/CmdListSecrets.py b/src/python/jw/pkg/cmds/secrets/CmdListSecrets.py index 95e5266d..bd4d7672 100644 --- a/src/python/jw/pkg/cmds/secrets/CmdListSecrets.py +++ b/src/python/jw/pkg/cmds/secrets/CmdListSecrets.py @@ -14,5 +14,9 @@ class CmdListSecrets(Cmd): # export def __init__(self, parent: CmdSecrets) -> None: 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: - 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))))