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

Function add_file_to_context

crates/chat-cli/src/cli/chat/context.rs:377–382  ·  view source on GitHub ↗

Add a file to the context collection. This method: 1. Reads the content of the file 2. Adds the (filename, content) pair to the context collection # Arguments `path` - The path to the file `context_files` - The collection to add the file to # Returns A Result indicating success or an error

(os: &Os, path: &Path, context_files: &mut Vec<(String, String)>)

Source from the content-addressed store, hash-verified

375/// # Returns
376/// A Result indicating success or an error
377async fn add_file_to_context(os: &Os, path: &Path, context_files: &mut Vec<(String, String)>) -> Result<()> {
378 let filename = path.to_string_lossy().to_string();
379 let content = os.fs.read_to_string(path).await?;
380 context_files.push((filename, content));
381 Ok(())
382}
383
384#[cfg(test)]
385mod tests {

Callers 1

process_pathFunction · 0.85

Calls 2

to_stringMethod · 0.80
read_to_stringMethod · 0.80

Tested by

no test coverage detected