Take a [PKGBUILD], create [SRCINFO] data from it and print it. # Errors Returns an error if - running the [`alpm-pkgbuild-bridge`] script fails, - or parsing the output of the ``alpm-pkgbuild-bridge`] script fails. [PKGBUILD]: https://man.archlinux.org/man/PKGBUILD.5 [SRCINFO]: https://alpm.archlinux.page/specifications/SRCINFO.5.html [`alpm-pkgbuild-bridge`]: https://gitlab.archlinux.org/arch
(
pkgbuild_path: &Path,
output_format: SourceInfoOutputFormat,
pretty: bool,
)
| 46 | /// [SRCINFO]: https://alpm.archlinux.page/specifications/SRCINFO.5.html |
| 47 | /// [`alpm-pkgbuild-bridge`]: https://gitlab.archlinux.org/archlinux/alpm/alpm-pkgbuild-bridge |
| 48 | pub fn create( |
| 49 | pkgbuild_path: &Path, |
| 50 | output_format: SourceInfoOutputFormat, |
| 51 | pretty: bool, |
| 52 | ) -> Result<(), Error> { |
| 53 | let source_info = SourceInfoV1::from_pkgbuild(pkgbuild_path)?; |
| 54 | |
| 55 | match output_format { |
| 56 | SourceInfoOutputFormat::Json => { |
| 57 | let json = if pretty { |
| 58 | serde_json::to_string_pretty(&source_info)? |
| 59 | } else { |
| 60 | serde_json::to_string(&source_info)? |
| 61 | }; |
| 62 | println!("{json}"); |
| 63 | } |
| 64 | SourceInfoOutputFormat::Srcinfo => { |
| 65 | print!("{}", source_info.as_srcinfo()) |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | Ok(()) |
| 70 | } |
| 71 | |
| 72 | /// Validates a SRCINFO file from a path or stdin. |
| 73 | /// |
no outgoing calls