Write output to a file and return a result with a confirmation message, or return self unchanged if no output path is given. This is a shared helper to avoid duplicating the write-to-file pattern across evaluate, navigate, snapshot, and screenshot commands.
(self, path: Option<&str>)
| 61 | /// This is a shared helper to avoid duplicating the write-to-file pattern |
| 62 | /// across evaluate, navigate, snapshot, and screenshot commands. |
| 63 | pub async fn save_output(self, path: Option<&str>) -> Result<Self, std::io::Error> { |
| 64 | match path { |
| 65 | Some(p) => { |
| 66 | fs::write(p, &self.output).await?; |
| 67 | Ok(CommandResult::output(format!("Output saved to {p}"))) |
| 68 | } |
| 69 | None => Ok(self), |
| 70 | } |
| 71 | } |
| 72 | } |
no outgoing calls
no test coverage detected