Skip to content

Commit

Permalink
refactor: change PackCommand parent (#4797)
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
  • Loading branch information
mr-cal authored Jun 11, 2024
1 parent f5e0025 commit b6f464c
Showing 1 changed file with 2 additions and 25 deletions.
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 @@ def _fill_parser(self, parser: argparse.ArgumentParser) -> None:
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 @@ def _run(
)
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)

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

0 comments on commit b6f464c

Please sign in to comment.