pub trait ConfigEnvironment: Send + Sync {
// Required methods
fn unified_config_path(&self) -> Option<PathBuf>;
fn file_exists(&self, path: &Path) -> bool;
fn read_file(&self, path: &Path) -> Result<String>;
fn write_file(&self, path: &Path, content: &str) -> Result<()>;
fn create_dir_all(&self, path: &Path) -> Result<()>;
// Provided method
fn prompt_path(&self) -> PathBuf { ... }
}Expand description
Trait for configuration environment access.
This trait abstracts all external side effects needed for configuration:
- Path resolution (which may depend on environment variables)
- File existence checks
- File reading and writing
- Directory creation
By injecting this trait, configuration code becomes pure and testable.
Required Methods§
Sourcefn unified_config_path(&self) -> Option<PathBuf>
fn unified_config_path(&self) -> Option<PathBuf>
Get the path to the unified config file.
In production, this returns ~/.config/ralph-workflow.toml or
$XDG_CONFIG_HOME/ralph-workflow.toml if the env var is set.
Returns None if the path cannot be determined (e.g., no home directory).
Sourcefn file_exists(&self, path: &Path) -> bool
fn file_exists(&self, path: &Path) -> bool
Check if a file exists at the given path.
Sourcefn write_file(&self, path: &Path, content: &str) -> Result<()>
fn write_file(&self, path: &Path, content: &str) -> Result<()>
Write content to a file, creating parent directories if needed.
Sourcefn create_dir_all(&self, path: &Path) -> Result<()>
fn create_dir_all(&self, path: &Path) -> Result<()>
Create directories recursively.
Provided Methods§
Sourcefn prompt_path(&self) -> PathBuf
fn prompt_path(&self) -> PathBuf
Get the path to the PROMPT.md file.
In production, this returns ./PROMPT.md (relative to current directory).
Tests may override this to use a different path.