Parses a file according to a BUILDINFO schema. Returns a serializable BuildInfo if the file is valid, otherwise an error is returned. NOTE: If a command is piped to this process, the input is read from stdin. See [`IsTerminal`] for more information about how terminal detection works. [`IsTerminal`]: https://doc.rust-lang.org/stable/std/io/trait.IsTerminal.html
(args: ValidateArgs)
| 120 | /// |
| 121 | /// [`IsTerminal`]: https://doc.rust-lang.org/stable/std/io/trait.IsTerminal.html |
| 122 | pub fn parse(args: ValidateArgs) -> Result<BuildInfo, Error> { |
| 123 | let build_info = if let Some(file) = &args.file { |
| 124 | BuildInfo::from_file_with_schema(file, args.schema)? |
| 125 | } else if !io::stdin().is_terminal() { |
| 126 | BuildInfo::from_stdin_with_schema(args.schema)? |
| 127 | } else { |
| 128 | Err(Error::NoInputFile)? |
| 129 | }; |
| 130 | |
| 131 | Ok(build_info) |
| 132 | } |
| 133 | |
| 134 | /// Validate a file according to a BUILDINFO schema. |
| 135 | /// |