Add the restore command.

This commit is contained in:
2025-01-17 20:49:28 +02:00
parent 87682a056f
commit b32e5d32b0
6 changed files with 88 additions and 1 deletions
@@ -22,8 +22,11 @@ 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.backup.application.service.backup_restore_service import \
BackupRestoreService
from tui_rsync.core.shared_kernel.components.common import UUID
from tui_rsync.infrastructure.configuration import CurrentConfiguration
from tui_rsync.user_interface.cli.shared_kernel.components.prompts.applications.prompts import ChoosePromptFzf
console = Console()
sync = typer.Typer()
@@ -42,7 +45,7 @@ def one(
)
):
"""
[green b]Sync[/] a [yellow]source[/] with the [yellow b]label[/] and its backups.
[green b]Sync[/] a [yellow]source[/] to [yellow]destination[/] for the [yellow b]backup plan id[/].
[yellow b]Skips[/] if not available.
"""
@@ -54,3 +57,31 @@ def one(
# TODO add args
service.sync_by_plan_id(UUID(id), '-avuP', dry)
@sync.command()
def restore(
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]destination[/] to the [yellow]source[/] for the [yellow b]backup plan id[/].
[yellow b]Skips[/] if not available.
"""
service: BackupRestoreService = CurrentConfiguration.get(BackupRestoreService)
choose_prompt: ChoosePromptFzf = CurrentConfiguration.get(ChoosePromptFzf)
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), choose_prompt, '-avuP', dry)