Add exporters, utils, and tests
This commit is contained in:
26
.termflow/utils/config.py
Normal file
26
.termflow/utils/config.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
"""Configuration utilities."""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
|
||||||
|
def load_config(config_path: Optional[str] = None) -> Dict[str, Any]:
|
||||||
|
"""Load configuration from file."""
|
||||||
|
if config_path is None:
|
||||||
|
config_path = os.environ.get("TERMFLOW_HOME", str(Path.home() / ".termflow"))
|
||||||
|
|
||||||
|
config_file = Path(config_path) / "config.yaml"
|
||||||
|
|
||||||
|
if config_file.exists():
|
||||||
|
import yaml
|
||||||
|
with open(config_file) as f:
|
||||||
|
return yaml.safe_load(f) or {}
|
||||||
|
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
def get_default_db_path() -> str:
|
||||||
|
"""Get the default database path."""
|
||||||
|
home = Path.home()
|
||||||
|
return str(home / ".termflow" / "sessions.db")
|
||||||
Reference in New Issue
Block a user