mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-12 17:57:43 +00:00
Update the repository to use exception for the delete action.
This commit is contained in:
@@ -23,13 +23,16 @@ import typer
|
||||
from tui_rsync.core.components.backup_plan.application.commands import RemoveAllBackupBackupPlansCommand
|
||||
from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService
|
||||
from tui_rsync.core.shared_kernel.components.common import UUID
|
||||
from tui_rsync.core.shared_kernel.ports.Exceptions import CommandException
|
||||
from tui_rsync.infrastructure.configuration import CurrentConfiguration
|
||||
from tui_rsync.user_interface.cli.shared_kernel.components.errors.applications.exceptions import catch_exception
|
||||
|
||||
console = Console()
|
||||
remove_backup_plan = typer.Typer()
|
||||
|
||||
|
||||
@remove_backup_plan.command()
|
||||
@catch_exception(CommandException, 1)
|
||||
def one(
|
||||
id: str = typer.Option(
|
||||
None, "--id", "-i",
|
||||
@@ -43,15 +46,7 @@ def one(
|
||||
|
||||
service: BackupPlanService = CurrentConfiguration.get(BackupPlanService)
|
||||
|
||||
if id is None:
|
||||
console.print("[red b][ERROR][/] Backup plan does not exists!!!")
|
||||
return
|
||||
|
||||
plan = service.delete(UUID(id))
|
||||
|
||||
if plan is None:
|
||||
console.print("[red b][ERROR][/] Backup plan does not exists!!!")
|
||||
return
|
||||
service.delete(UUID(id))
|
||||
|
||||
console.print(f"Removed the backup plan with {id}.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user