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

Method validate

crates/chat-cli/src/cli/chat/tools/fs_write.rs:389–413  ·  view source on GitHub ↗
(&mut self, os: &Os)

Source from the content-addressed store, hash-verified

387 }
388
389 pub async fn validate(&mut self, os: &Os) -> Result<()> {
390 match self {
391 FsWrite::Create { path, .. } => {
392 if path.is_empty() {
393 bail!("Path must not be empty")
394 };
395 },
396 FsWrite::StrReplace { path, .. } | FsWrite::Insert { path, .. } => {
397 let path = sanitize_path_tool_arg(os, path);
398 if !path.exists() {
399 bail!("The provided path must exist in order to replace or insert contents into it")
400 }
401 },
402 FsWrite::Append { path, new_str, .. } => {
403 if path.is_empty() {
404 bail!("Path must not be empty")
405 };
406 if new_str.is_empty() {
407 bail!("Content to append must not be empty")
408 };
409 },
410 }
411
412 Ok(())
413 }
414
415 fn print_relative_path(&self, os: &Os, output: &mut impl Write) -> Result<()> {
416 let cwd = os.env.current_dir()?;

Callers

nothing calls this directly

Calls 3

sanitize_path_tool_argFunction · 0.85
is_emptyMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected