Private
Public Access
0
0

feat(paths): remove SLOP_CONFIG env-var fallback; add --config CLI flag (FR2)

This commit is contained in:
2026-06-19 07:45:10 -04:00
parent 49bc4908e6
commit 02fef00470
5 changed files with 136 additions and 22 deletions
-2
View File
@@ -191,8 +191,6 @@ def _save_config_to_disk(config: dict[str, Any]) -> None:
# only when the user actually saves config.
import tomli_w
config = _clean_nones(config)
sys.stderr.write(f"[DEBUG] Saving config. Theme: {config.get('theme')}\n")
sys.stderr.flush()
with open(get_config_path(), "wb") as f:
tomli_w.dump(config, f)
+25 -2
View File
@@ -49,12 +49,35 @@ from typing import Optional, Any
_RESOLVED: dict[str, Path] = {}
_CONFIG_OVERRIDE: Path | None = None
def set_config_override(path: Path | None) -> None:
"""
Set the active config.toml path. Pass None to use the default
<project_root>/config.toml. The CLI --config flag is the ONLY
supported override mechanism; the historical SLOP_CONFIG env var
fallback has been removed (per test_sandbox_hardening_20260619 FR2).
[C: sloppy.py:main, tests/conftest.py]
"""
global _CONFIG_OVERRIDE
_CONFIG_OVERRIDE = path
_RESOLVED.clear()
def get_config_path() -> Path:
"""
[C: tests/test_paths.py:test_default_paths]
Returns the active config.toml. If a CLI override is set, returns it.
Otherwise returns the default <project_root>/config.toml.
[C: src/app_controller.py:AppController.load_config,
src/app_controller.py:AppController.init_state,
src/models.py:_load_config_from_disk,
tests/test_test_sandbox.py]
"""
if _CONFIG_OVERRIDE is not None:
return _CONFIG_OVERRIDE
root_dir = Path(__file__).resolve().parent.parent
return Path(os.environ.get("SLOP_CONFIG", root_dir / "config.toml"))
return root_dir / "config.toml"
def get_global_presets_path() -> Path:
"""