Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: change PackCommand parent #4797

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions snapcraft/commands/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"""Snapcraft lifecycle commands."""

import argparse
import pathlib
import textwrap
from typing import Any

Expand All @@ -29,7 +28,7 @@
import snapcraft.pack


class PackCommand(craft_application.commands.LifecycleCommand):
class PackCommand(craft_application.commands.lifecycle.PackCommand):
"""Snapcraft pack command."""

name = "pack"
Expand All @@ -55,13 +54,6 @@
default=None,
help="Directory to pack",
)
parser.add_argument(
"--output",
"-o",
type=pathlib.Path,
default=pathlib.Path(),
help="Output directory for created packages",
)

@override
def _run(
Expand All @@ -78,22 +70,7 @@
)
emit.message(f"Packed {snap_filename}")
else:
super()._run(parsed_args, step_name="prime")
self._services.package.update_project()
self._services.package.write_metadata(self._services.lifecycle.prime_dir)

emit.progress("Packing...")
packages = self._services.package.pack(
self._services.lifecycle.prime_dir, parsed_args.output
)

if not packages:
emit.progress("No packages created.", permanent=True)
elif len(packages) == 1:
emit.progress(f"Packed {packages[0].name}", permanent=True)
else:
package_names = ", ".join(pkg.name for pkg in packages)
emit.progress(f"Packed: {package_names}", permanent=True)
super()._run(parsed_args)

Check warning on line 73 in snapcraft/commands/lifecycle.py

View check run for this annotation

Codecov / codecov/patch

snapcraft/commands/lifecycle.py#L73

Added line #L73 was not covered by tests

@override
def needs_project(self, parsed_args: argparse.Namespace) -> bool:
Expand Down
Loading