From d26b016a74c96d55ad75d38d07d4005d0df1866f Mon Sep 17 00:00:00 2001 From: Callahan Kovacs Date: Wed, 8 May 2024 12:29:15 -0500 Subject: [PATCH] chore: move part-specific call to LifecyclePartsCommand Signed-off-by: Callahan Kovacs --- craft_application/commands/lifecycle.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/craft_application/commands/lifecycle.py b/craft_application/commands/lifecycle.py index 2e775489..515ee96c 100644 --- a/craft_application/commands/lifecycle.py +++ b/craft_application/commands/lifecycle.py @@ -188,7 +188,6 @@ def _run( shell = getattr(parsed_args, "shell", False) shell_after = getattr(parsed_args, "shell_after", False) debug = getattr(parsed_args, "debug", False) - parts = getattr(parsed_args, "parts", None) step_name = step_name or self.name @@ -198,10 +197,7 @@ def _run( shell_after = True try: - self._services.lifecycle.run( - step_name=step_name, - part_names=parts, - ) + self._run_lifecycle(parsed_args, step_name) except Exception as err: if debug: emit.progress(str(err), permanent=True) @@ -211,6 +207,14 @@ def _run( if shell_after: _launch_shell() + def _run_lifecycle( + self, + parsed_args: argparse.Namespace, # noqa: ARG002 (unused argument is for subclasses) + step_name: str | None = None, + ) -> None: + """Run the lifecycle.""" + self._services.lifecycle.run(step_name=step_name) + @staticmethod def _should_add_shell_args() -> bool: return True @@ -233,6 +237,16 @@ def _fill_parser(self, parser: argparse.ArgumentParser) -> None: help="Optional list of parts to process", ) + @override + def _run_lifecycle( + self, parsed_args: argparse.Namespace, step_name: str | None = None + ) -> None: + """Run the lifecycle, optionally for a part or list of parts.""" + self._services.lifecycle.run( + step_name=step_name, + part_names=parsed_args.parts, + ) + class PullCommand(LifecyclePartsCommand): """Command to pull parts."""