Update the show all plans command to show if there're no plans.

This commit is contained in:
2025-01-27 12:06:58 +02:00
parent b999975695
commit 9729f442c2
15 changed files with 157 additions and 40 deletions
@@ -20,7 +20,8 @@
from rich.console import Console
import typer
from tui_rsync.core.components.backup_plan.application.queries import GetAllBackupBackupPlansQuery
from tui_rsync.core.components.backup_plan.application.services import GetAllBackupPlansService, \
GetBackupPlanCountService
from tui_rsync.core.components.backup_plan.application.services.backup_plan_service import BackupPlanService
from tui_rsync.core.shared_kernel.components.common import UUID
@@ -48,16 +49,8 @@ def one(
service: BackupPlanService = CurrentConfiguration.get(BackupPlanService)
if id is None:
console.print("[red b][ERROR][/] Backup plan does not exists!!!")
return
plan = service.get_by_id(UUID(id))
if plan is None:
console.print("[red b][ERROR][/] Backup plan does not exists!!!")
return
console.print(BackupPlanFormat.format(plan))
@@ -67,7 +60,10 @@ def all():
[green b]Show[/] [yellow]all existing backup plans[/].
"""
query = CurrentConfiguration.get(GetAllBackupBackupPlansQuery)
for backup_plan in query.execute():
console.print(BackupPlanFormat.format(backup_plan))
count_service = CurrentConfiguration.get(GetBackupPlanCountService)
if count_service.is_empty():
console.print("No backup plans.")
else:
service = CurrentConfiguration.get(GetAllBackupPlansService)
for backup_plan in service.get_all():
console.print(BackupPlanFormat.format(backup_plan))