46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""
|
|
Base CLI class and utilities for NimbusFlow CLI.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
from backend.db.connection import DatabaseConnection
|
|
from backend.repositories import (
|
|
MemberRepository,
|
|
ClassificationRepository,
|
|
ServiceRepository,
|
|
ServiceAvailabilityRepository,
|
|
ScheduleRepository,
|
|
ServiceTypeRepository
|
|
)
|
|
|
|
|
|
class CLIError(Exception):
|
|
"""Custom exception for CLI-specific errors."""
|
|
pass
|
|
|
|
|
|
class NimbusFlowCLI:
|
|
"""Main CLI application class."""
|
|
|
|
def __init__(self, db_path: str = "database6_accepts_and_declines.db"):
|
|
"""Initialize CLI with database connection."""
|
|
self.db_path = Path(__file__).parent.parent / db_path
|
|
if not self.db_path.exists():
|
|
raise CLIError(f"Database not found: {self.db_path}")
|
|
|
|
self.db = DatabaseConnection(self.db_path)
|
|
self._init_repositories()
|
|
|
|
def _init_repositories(self):
|
|
"""Initialize all repository instances."""
|
|
self.member_repo = MemberRepository(self.db)
|
|
self.classification_repo = ClassificationRepository(self.db)
|
|
self.service_repo = ServiceRepository(self.db)
|
|
self.availability_repo = ServiceAvailabilityRepository(self.db)
|
|
self.schedule_repo = ScheduleRepository(self.db)
|
|
self.service_type_repo = ServiceTypeRepository(self.db)
|
|
|
|
def close(self):
|
|
"""Clean up database connection."""
|
|
if hasattr(self, 'db'):
|
|
self.db.close() |