From f652eb0a60c2b2e8fd61c0fa7c6dc3067eca8473 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Fri, 30 Jan 2026 05:28:37 +0000 Subject: [PATCH] Add core modules (session, recorder, database) --- .termflow/config.py | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .termflow/config.py diff --git a/.termflow/config.py b/.termflow/config.py new file mode 100644 index 0000000..8f50a47 --- /dev/null +++ b/.termflow/config.py @@ -0,0 +1,53 @@ +"""Configuration management for Term Flow.""" + +import os +from pathlib import Path +from typing import Optional + +import yaml + + +class Config: + """Configuration manager for Term Flow.""" + + def __init__(self): + self._config_dir = Path(os.environ.get("TERMFLOW_HOME", Path.home() / ".termflow")) + self._config_dir.mkdir(parents=True, exist_ok=True) + self._db_path = os.environ.get( + "TERMFLOW_DB", + str(self._config_dir / "sessions.db") + ) + self._git_cache = os.environ.get( + "TERMFLOW_GIT_CACHE", + str(self._config_dir / "git_cache") + ) + self._default_style = os.environ.get("TERMFLOW_STYLE", "detailed") + + @property + def config_dir(self) -> Path: + return self._config_dir + + @property + def db_path(self) -> str: + return self._db_path + + @property + def git_cache(self) -> str: + return self._git_cache + + @property + def default_style(self) -> str: + return self._default_style + + def get_session_db_path(self) -> str: + Path(self._db_path).parent.mkdir(parents=True, exist_ok=True) + return self._db_path + + def get_git_cache_dir(self) -> str: + Path(self._git_cache).mkdir(parents=True, exist_ok=True) + return self._git_cache + + +def get_config() -> Config: + """Get the current configuration.""" + return Config()