MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / write_rules_file

Function write_rules_file

rust/src/rules.rs:34–51  ·  view source on GitHub ↗

Writes the Selenium LLM rules file to the given path, creating parent directories as needed. # Arguments `path` - Destination file path (e.g. `rules/selenium.md`) `log` - Logger instance # Errors Returns an error if the file already exists or cannot be written.

(path: &Path, log: &Logger)

Source from the content-addressed store, hash-verified

32/// # Errors
33/// Returns an error if the file already exists or cannot be written.
34pub fn write_rules_file(path: &Path, log: &Logger) -> Result<(), Error> {
35 log.debug(format!("Creating rules file at: {}", path.display()));
36 if path.exists() {
37 return Err(anyhow!(
38 "The file {} already exists. Please remove it or choose a different location.",
39 path.display()
40 ));
41 }
42 if let Some(parent) = path.parent() {
43 if !parent.exists() {
44 log.debug(format!("Creating directory: {}", parent.display()));
45 std::fs::create_dir_all(parent)?;
46 }
47 }
48 let mut file = OpenOptions::new().write(true).create_new(true).open(path)?;
49 file.write_all(RULES_CONTENT.as_bytes())?;
50 Ok(())
51}

Callers 1

mainFunction · 0.85

Calls 5

existsMethod · 0.80
parentMethod · 0.80
openMethod · 0.80
debugMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected