(&mut self, os: &Os)
| 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()?; |
nothing calls this directly
no test coverage detected