(&self)
| 53 | |
| 54 | impl InputArgs { |
| 55 | pub fn sources(&self) -> Result<Vec<(&str, InputSource<'_>)>> { |
| 56 | if let Some(content) = &self.content { |
| 57 | Ok(vec![("<content>", InputSource::Content(Cursor::new(content)))]) |
| 58 | } else { |
| 59 | let mut sources = Vec::new(); |
| 60 | for file in &self.files { |
| 61 | let source = if file == "-" { |
| 62 | InputSource::Stdin(stdin().lock()) |
| 63 | } else { |
| 64 | InputSource::File(BufReader::new(File::open(file)?)) |
| 65 | }; |
| 66 | sources.push((file.as_str(), source)); |
| 67 | } |
| 68 | Ok(sources) |
| 69 | } |
| 70 | } |
| 71 | } |