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."""