MCPcopy Create free account
hub / github.com/Wulf/create-rust-app / append

Function append

crates/create-rust-app_cli/src/utils/fs.rs:126–139  ·  view source on GitHub ↗
(file_path: &str, content: &str)

Source from the content-addressed store, hash-verified

124*/
125
126pub fn append(file_path: &str, content: &str) -> Result<()> {
127 modify_file_msg(&format!("{:#?}", &file_path));
128
129 let (file_path, file_contents) = read(file_path)?;
130
131 let mut new_content = String::new();
132 new_content.push_str(file_contents.as_str());
133 new_content.push('\n');
134 new_content.push_str(content);
135
136 std::fs::write(file_path, new_content)?;
137
138 Ok(())
139}
140
141pub fn replace(file_path: &str, from: &str, to: &str) -> Result<()> {
142 modify_file_msg(&format!("{:#?}", &file_path));

Callers 4

installMethod · 0.85
installMethod · 0.85
installMethod · 0.85
installMethod · 0.85

Calls 2

modify_file_msgFunction · 0.85
readFunction · 0.85

Tested by

no test coverage detected