feat(backend): design the cli to look professional
This commit is contained in:
@@ -10,12 +10,11 @@ if TYPE_CHECKING:
|
||||
from backend.cli.base import NimbusFlowCLI
|
||||
|
||||
from backend.models.enums import ScheduleStatus
|
||||
from backend.cli.utils import format_service_row, create_table_header, create_table_separator, TableColors
|
||||
|
||||
|
||||
def cmd_services_list(cli: "NimbusFlowCLI", args) -> None:
|
||||
"""List services with optional filters."""
|
||||
print("Listing services...")
|
||||
|
||||
# Apply filters
|
||||
if args.upcoming:
|
||||
services = cli.service_repo.upcoming(limit=args.limit or 50)
|
||||
@@ -26,7 +25,7 @@ def cmd_services_list(cli: "NimbusFlowCLI", args) -> None:
|
||||
all_services = cli.service_repo.list_all()
|
||||
services = [s for s in all_services if s.ServiceDate == target_date]
|
||||
except ValueError:
|
||||
print(f"❌ Invalid date format '{args.date}'. Use YYYY-MM-DD")
|
||||
print(f"{TableColors.ERROR}Invalid date format '{args.date}'. Use YYYY-MM-DD{TableColors.RESET}")
|
||||
return
|
||||
else:
|
||||
services = cli.service_repo.list_all()
|
||||
@@ -34,7 +33,7 @@ def cmd_services_list(cli: "NimbusFlowCLI", args) -> None:
|
||||
services = services[:args.limit]
|
||||
|
||||
if not services:
|
||||
print("No services found.")
|
||||
print(f"{TableColors.DIM}No services found.{TableColors.RESET}")
|
||||
return
|
||||
|
||||
# Get service type names for display
|
||||
@@ -57,22 +56,19 @@ def cmd_services_list(cli: "NimbusFlowCLI", args) -> None:
|
||||
'total': len(service_schedules)
|
||||
}
|
||||
|
||||
# Print header
|
||||
print(f"\n{'ID':<3} | {'Date':<12} | {'Service Type':<12} | {'Total':<5} | {'Pending':<7} | {'Accepted':<8} | {'Declined'}")
|
||||
print("-" * 85)
|
||||
# Print styled header
|
||||
print()
|
||||
print(create_table_header("ID ", "Date ", "Service Type ", "Total", "Pending", "Accepted", "Declined"))
|
||||
print(create_table_separator(85))
|
||||
|
||||
# Print services
|
||||
for service in sorted(services, key=lambda s: s.ServiceDate):
|
||||
type_name = service_type_map.get(service.ServiceTypeId, "Unknown")
|
||||
counts = schedule_counts.get(service.ServiceId, {'total': 0, 'pending': 0, 'accepted': 0, 'declined': 0})
|
||||
|
||||
# Format date properly
|
||||
date_str = str(service.ServiceDate) if service.ServiceDate else "N/A"
|
||||
|
||||
print(f"{service.ServiceId:<3} | {date_str:<12} | {type_name:<12} | "
|
||||
f"{counts['total']:<5} | {counts['pending']:<7} | {counts['accepted']:<8} | {counts['declined']}")
|
||||
print(format_service_row(service, type_name, counts))
|
||||
|
||||
print(f"\nTotal: {len(services)} services")
|
||||
print()
|
||||
print(f"{TableColors.SUCCESS}Total: {len(services)} services{TableColors.RESET}")
|
||||
|
||||
|
||||
def setup_services_parser(subparsers) -> None:
|
||||
|
||||
Reference in New Issue
Block a user