Add the sync command.

dev
KKlochko 4 months ago
parent 359dcdfca6
commit 87682a056f

@ -1,8 +1,7 @@
from injector import Injector from injector import Injector
from tui_rsync.infrastructure.configuration import UserDataPaths from tui_rsync.infrastructure.configuration import UserDataPaths
from tui_rsync.infrastructure.configuration.configuration import Configuration from tui_rsync.infrastructure.configuration import Configuration, CurrentConfiguration
from tui_rsync.infrastructure.configuration.current_configuration import CurrentConfiguration
from tui_rsync.user_interface.cli.cli import cli_app from tui_rsync.user_interface.cli.cli import cli_app

@ -19,8 +19,10 @@
from rich.console import Console from rich.console import Console
import typer import typer
from .components.backup import sync
from .components.backup_plan import backup_plan from .components.backup_plan import backup_plan
console = Console() console = Console()
cli_app = typer.Typer(rich_markup_mode="rich") cli_app = typer.Typer(rich_markup_mode="rich")
cli_app.add_typer(backup_plan, name="plans", help="Manage backup plans") cli_app.add_typer(backup_plan, name="plans", help="Manage backup plans")
cli_app.add_typer(sync, name="sync", help="Sync as planned")

@ -0,0 +1,3 @@
from .backup import sync
__all__ = ['sync']

@ -0,0 +1,56 @@
################################################################################
# Copyright (C) 2023-2025 Kostiantyn Klochko <kklochko@protonmail.com> #
# #
# 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 <https://www.gnu.org/licenses/>. #
################################################################################
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)
Loading…
Cancel
Save