30 lines
774 B
Python
30 lines
774 B
Python
from pathlib import Path
|
|
|
|
import typer
|
|
import yaml
|
|
from rich.console import Console
|
|
|
|
from src.config import Config
|
|
|
|
CONSOLE = Console()
|
|
CONFIG_OPT = typer.Option("config.yaml", "--config", "-c", help="Path to config file")
|
|
|
|
|
|
def load_config(path: str = "config.yaml") -> Config:
|
|
config_path = Path(path)
|
|
if not config_path.exists():
|
|
raise FileNotFoundError(
|
|
f"Config file not found: {config_path}. Run 'qc-cli init' to create one."
|
|
)
|
|
with open(config_path) as f:
|
|
data = yaml.safe_load(f)
|
|
return Config.model_validate(data)
|
|
|
|
|
|
def load_cfg(path: str = "config.yaml") -> Config:
|
|
try:
|
|
return load_config(path)
|
|
except FileNotFoundError as e:
|
|
CONSOLE.print(f"[red]{e}[/red]")
|
|
raise typer.Exit(1)
|