diff --git a/tui_rsync/main.py b/tui_rsync/main.py index 60295df..388affd 100644 --- a/tui_rsync/main.py +++ b/tui_rsync/main.py @@ -1,8 +1,7 @@ from injector import Injector from tui_rsync.infrastructure.configuration import UserDataPaths -from tui_rsync.infrastructure.configuration.configuration import Configuration -from tui_rsync.infrastructure.configuration.current_configuration import CurrentConfiguration +from tui_rsync.infrastructure.configuration import Configuration, CurrentConfiguration from tui_rsync.user_interface.cli.cli import cli_app diff --git a/tui_rsync/user_interface/cli/cli.py b/tui_rsync/user_interface/cli/cli.py index cde782f..106ebee 100644 --- a/tui_rsync/user_interface/cli/cli.py +++ b/tui_rsync/user_interface/cli/cli.py @@ -19,8 +19,10 @@ from rich.console import Console import typer +from .components.backup import sync from .components.backup_plan import backup_plan console = Console() cli_app = typer.Typer(rich_markup_mode="rich") cli_app.add_typer(backup_plan, name="plans", help="Manage backup plans") +cli_app.add_typer(sync, name="sync", help="Sync as planned") diff --git a/tui_rsync/user_interface/cli/components/backup/__init__.py b/tui_rsync/user_interface/cli/components/backup/__init__.py new file mode 100644 index 0000000..c7255ec --- /dev/null +++ b/tui_rsync/user_interface/cli/components/backup/__init__.py @@ -0,0 +1,3 @@ +from .backup import sync + +__all__ = ['sync'] diff --git a/tui_rsync/user_interface/cli/components/backup/backup.py b/tui_rsync/user_interface/cli/components/backup/backup.py new file mode 100644 index 0000000..39802f2 --- /dev/null +++ b/tui_rsync/user_interface/cli/components/backup/backup.py @@ -0,0 +1,56 @@ +################################################################################ +# Copyright (C) 2023-2025 Kostiantyn Klochko # +# # +# This file is part of tui-rsync. # +# # +# tui-rsync is free software: you can redistribute it and/or modify it under # +# the terms of the GNU General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# tui-rsync is distributed in the hope that it will be useful, but WITHOUT ANY # +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # +# details. # +# # +# You should have received a copy of the GNU General Public License along with # +# tui-rsync. If not, see . # +################################################################################ + + +from rich.console import Console +import typer + +from tui_rsync.core.shared_kernel.components.backup.application.service import BackupSyncService +from tui_rsync.core.shared_kernel.components.common import UUID +from tui_rsync.infrastructure.configuration import CurrentConfiguration + +console = Console() +sync = typer.Typer() + + +@sync.command() +def one( + id: str = typer.Option( + None, "--id", "-i", + help="[b]The id[/] is an uniq identification of a [b]backup plan[/].", + show_default=False + ), + dry: bool = typer.Option( + False, "-d", "--dry-run", + help="The command will [b]show[/] information about what will be changed.", + ) +): + """ + [green b]Sync[/] a [yellow]source[/] with the [yellow b]label[/] and its backups. + [yellow b]Skips[/] if not available. + """ + + service: BackupSyncService = CurrentConfiguration.get(BackupSyncService) + + if id is None: + console.print("[red b][ERROR][/] Backup plan does not exists!!!") + return + + # TODO add args + service.sync_by_plan_id(UUID(id), '-avuP', dry)