MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / write_to_file

Function write_to_file

crates/chat-cli/src/cli/chat/tools/fs_write.rs:567–577  ·  view source on GitHub ↗

Writes `content` to `path`, adding a newline if necessary.

(os: &Os, path: impl AsRef<Path>, mut content: String)

Source from the content-addressed store, hash-verified

565
566/// Writes `content` to `path`, adding a newline if necessary.
567async fn write_to_file(os: &Os, path: impl AsRef<Path>, mut content: String) -> Result<()> {
568 let path_ref = path.as_ref();
569 // Log the path being written to
570 tracing::debug!("Writing to file: {:?}", path_ref);
571
572 if !content.ends_with_newline() {
573 content.push('\n');
574 }
575 os.fs.write(path.as_ref(), content).await?;
576 Ok(())
577}
578
579/// Returns a prefix/suffix pair before and after the content dictated by `[start_line, end_line]`
580/// within `content`. The updated start and end lines containing the original context along with

Callers 1

invokeMethod · 0.85

Calls 2

as_refMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected