diff --git a/flake-info/src/data/export.rs b/flake-info/src/data/export.rs index cfb23fc..4e08e41 100644 --- a/flake-info/src/data/export.rs +++ b/flake-info/src/data/export.rs @@ -5,7 +5,9 @@ use std::path::PathBuf; use crate::data::import::NixOption; use log::error; -use pandoc::{InputFormat, InputKind, OutputFormat, OutputKind, PandocOption, PandocOutput, PandocError}; +use pandoc::{ + InputFormat, InputKind, OutputFormat, OutputKind, PandocError, PandocOption, PandocOutput, +}; use serde::{Deserialize, Serialize}; use super::{ @@ -216,10 +218,13 @@ impl From for Derivation { .map(|l: &License| l.fullName.to_owned()) .collect(); - let package_maintainers = package + let package_maintainers: Vec = package .meta .maintainers - .map_or(Default::default(), Flatten::flatten); + .map_or(Default::default(), Flatten::flatten) + .into_iter() + .map(Into::into) + .collect(); let package_maintainers_set = package_maintainers .iter() @@ -316,7 +321,10 @@ impl From for Derivation { PandocOption::LuaFilter(man_filter), ]); - let result = pandoc.execute().expect(&format!("Pandoc could not parse documentation of '{}'", name)); + let result = pandoc.execute().expect(&format!( + "Pandoc could not parse documentation of '{}'", + name + )); match result { PandocOutput::ToBuffer(description) => Some(description), @@ -342,7 +350,33 @@ impl From for Derivation { } } -type Maintainer = import::Maintainer; +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct Maintainer { + name: Option, + github: Option, + email: Option, +} + +impl From for Maintainer { + fn from(import: import::Maintainer) -> Self { + match import { + import::Maintainer::Full { + name, + github, + email, + } => Maintainer { + name, + github, + email, + }, + import::Maintainer::Simple(name) => Maintainer { + name: Some(name), + github: None, + email: None, + }, + } + } +} impl From for Maintainer { fn from(flake: super::Flake) -> Self { diff --git a/flake-info/src/data/import.rs b/flake-info/src/data/import.rs index 70dc60b..78024c7 100644 --- a/flake-info/src/data/import.rs +++ b/flake-info/src/data/import.rs @@ -98,10 +98,14 @@ pub struct Meta { } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct Maintainer { - pub name: Option, - pub github: Option, - pub email: Option, +#[serde(untagged)] +pub enum Maintainer { + Full { + name: Option, + github: Option, + email: Option, + }, + Simple(String), } arg_enum! { @@ -267,7 +271,8 @@ mod tests { "github": "AndersonTorres", "githubId": 5954806, "name": "Anderson Torres" - } + }, + "Fred Flintstone" ], "name": "0verkill-unstable-2011-01-13", "outputsToInstall": [