smith.application.connect

Connect use-case — wire a project to a template source.

 1"""Connect use-case — wire a project to a template source."""
 2
 3from __future__ import annotations
 4
 5from pathlib import Path
 6
 7from smith.domain.connection import Connection
 8from smith.domain.value_objects import TemplateSource
 9from smith.infrastructure.filesystem import AtomicFileSystem
10from smith.infrastructure.gitignore import GitignoreManager
11from smith.infrastructure.metadata import SectionMetadata
12from smith.infrastructure.template_source import TemplateSourceAdapter
13
14
15class ConnectUseCase:
16    """Orchestrate the connection of a project to a template source."""
17
18    def __init__(self, project_dir: Path) -> None:
19        """Initialise with the target project directory."""
20        self._project_dir = project_dir
21
22    def execute(self, source: TemplateSource, overwrite: bool = False) -> None:
23        """Connect the project to the given template source."""
24        connection = Connection(
25            template_source_port=TemplateSourceAdapter(source),
26            filesystem_port=AtomicFileSystem(self._project_dir),
27            gitignore_port=GitignoreManager(self._project_dir),
28            metadata_port=SectionMetadata(self._project_dir),
29        )
30        connection.connect(source=source, overwrite=overwrite)
class ConnectUseCase:
16class ConnectUseCase:
17    """Orchestrate the connection of a project to a template source."""
18
19    def __init__(self, project_dir: Path) -> None:
20        """Initialise with the target project directory."""
21        self._project_dir = project_dir
22
23    def execute(self, source: TemplateSource, overwrite: bool = False) -> None:
24        """Connect the project to the given template source."""
25        connection = Connection(
26            template_source_port=TemplateSourceAdapter(source),
27            filesystem_port=AtomicFileSystem(self._project_dir),
28            gitignore_port=GitignoreManager(self._project_dir),
29            metadata_port=SectionMetadata(self._project_dir),
30        )
31        connection.connect(source=source, overwrite=overwrite)

Orchestrate the connection of a project to a template source.

ConnectUseCase(project_dir: pathlib._local.Path)
19    def __init__(self, project_dir: Path) -> None:
20        """Initialise with the target project directory."""
21        self._project_dir = project_dir

Initialise with the target project directory.

def execute( self, source: smith.domain.value_objects.TemplateSource, overwrite: bool = False) -> None:
23    def execute(self, source: TemplateSource, overwrite: bool = False) -> None:
24        """Connect the project to the given template source."""
25        connection = Connection(
26            template_source_port=TemplateSourceAdapter(source),
27            filesystem_port=AtomicFileSystem(self._project_dir),
28            gitignore_port=GitignoreManager(self._project_dir),
29            metadata_port=SectionMetadata(self._project_dir),
30        )
31        connection.connect(source=source, overwrite=overwrite)

Connect the project to the given template source.