mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-09-16 02:17:43 +00:00
Update the replace command to show responses.
This commit is contained in:
+4
-1
@@ -29,7 +29,10 @@ class BackupPlanRepository(BackupPlanRepositoryPort):
|
|||||||
|
|
||||||
def update(self, backup_plan: BackupPlan):
|
def update(self, backup_plan: BackupPlan):
|
||||||
updated_model = BackupPlanDTO.to_model(backup_plan)
|
updated_model = BackupPlanDTO.to_model(backup_plan)
|
||||||
model = BackupPlanModel.get_or_none(BackupPlanModel.id == updated_model.id)
|
query = GetBackupPlanByIdQuery(self.databaseManager)
|
||||||
|
|
||||||
|
old_plan = query.execute(backup_plan.id)
|
||||||
|
model = BackupPlanDTO.to_model(old_plan)
|
||||||
remove_backup_plan_destinations_command = RemoveBackupPlanDestinationsCommand(self.databaseManager)
|
remove_backup_plan_destinations_command = RemoveBackupPlanDestinationsCommand(self.databaseManager)
|
||||||
|
|
||||||
model.label = updated_model.label
|
model.label = updated_model.label
|
||||||
|
|||||||
@@ -24,14 +24,18 @@ import typer
|
|||||||
from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService
|
from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService
|
||||||
from tui_rsync.core.components.backup_plan.domain import BackupPlan, Source, Destination, BackupPlanId
|
from tui_rsync.core.components.backup_plan.domain import BackupPlan, Source, Destination, BackupPlanId
|
||||||
from tui_rsync.core.shared_kernel.components.common import Label
|
from tui_rsync.core.shared_kernel.components.common import Label
|
||||||
|
from tui_rsync.core.shared_kernel.ports.Exceptions import CommandException
|
||||||
|
from tui_rsync.core.shared_kernel.ports.Exceptions.query_exception import QueryException
|
||||||
from tui_rsync.infrastructure.configuration import CurrentConfiguration
|
from tui_rsync.infrastructure.configuration import CurrentConfiguration
|
||||||
|
from tui_rsync.user_interface.cli.shared_kernel.components.errors.applications.exceptions import catch_exception
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
update_backup_plan = typer.Typer()
|
update_backup_plan = typer.Typer()
|
||||||
|
|
||||||
|
|
||||||
@update_backup_plan.command()
|
@update_backup_plan.command()
|
||||||
|
@catch_exception(CommandException, 1)
|
||||||
|
@catch_exception(QueryException, 1)
|
||||||
def replace(
|
def replace(
|
||||||
id: str = typer.Option(
|
id: str = typer.Option(
|
||||||
None, "--id", "-i",
|
None, "--id", "-i",
|
||||||
@@ -65,3 +69,5 @@ def replace(
|
|||||||
plan = BackupPlan(id=BackupPlanId(id), label=Label(label), source=Source(source), destinations=[Destination(path) for path in destinations])
|
plan = BackupPlan(id=BackupPlanId(id), label=Label(label), source=Source(source), destinations=[Destination(path) for path in destinations])
|
||||||
service.update(plan)
|
service.update(plan)
|
||||||
|
|
||||||
|
console.print("The backup plan updated.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user