MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / write_toml_file

Function write_toml_file

src/agents/mod.rs:1454–1462  ·  view source on GitHub ↗

Write a TOML value to a file, backing up any existing file first.

(path: &Path, value: &toml::Value)

Source from the content-addressed store, hash-verified

1452
1453/// Write a TOML value to a file, backing up any existing file first.
1454pub fn write_toml_file(path: &Path, value: &toml::Value) -> Result<()> {
1455 backup_file(path)?;
1456 let contents = toml::to_string_pretty(value).unwrap_or_else(|_| String::new());
1457 std::fs::write(path, contents).map_err(|e| TraceDecayError::Config {
1458 message: format!("failed to write {}: {e}", path.display()),
1459 })?;
1460 eprintln!("\x1b[32m✔\x1b[0m Wrote {}", path.display());
1461 Ok(())
1462}
1463
1464// ---------------------------------------------------------------------------
1465// Git post-commit hook

Calls 2

backup_fileFunction · 0.85
writeFunction · 0.85