diff --git a/coffee_github/src/repository.rs b/coffee_github/src/repository.rs index b0187e20..7c4dc885 100644 --- a/coffee_github/src/repository.rs +++ b/coffee_github/src/repository.rs @@ -87,9 +87,15 @@ impl Github { let conf_file = serde_yaml::from_str::(&conf_str) .map_err(|err| error!("Coffee manifest malformed: {err}"))?; - plugin_name = Some(conf_file.plugin.name.to_string()); + let Some(ref plugin) = conf_file.plugin else { + // FIXME: read the binary information and store it anywhere + break; + }; + + plugin_name = Some(plugin.name.to_string()); path_to_plugin = Some(root_path.to_owned()); - let conf_lang = (&conf_file.plugin.lang).to_owned(); + + let conf_lang = (&plugin.lang).to_owned(); match conf_lang.as_str() { "pypip" => plugin_lang = PluginLang::PyPip, "pypoetry" => plugin_lang = PluginLang::PyPoetry, diff --git a/coffee_lib/src/plugin.rs b/coffee_lib/src/plugin.rs index d9b92ec4..4fb15695 100644 --- a/coffee_lib/src/plugin.rs +++ b/coffee_lib/src/plugin.rs @@ -111,9 +111,12 @@ impl Plugin { /// In case of success return the path of the executable. pub async fn configure(&mut self, verbose: bool) -> Result { let exec_path = if let Some(conf) = &self.conf { - if let Some(script) = &conf.plugin.install { + let Some(ref plugin) = conf.plugin else { + return Err(error!("plugin {self} is not a plugin")); + }; + if let Some(script) = &plugin.install { sh!(self.root_path.clone(), script, verbose); - format!("{}/{}", self.path, conf.plugin.main) + format!("{}/{}", self.path, plugin.main) } else { self.lang .default_install(&self.path, &self.name, verbose) diff --git a/coffee_lib/src/plugin_conf.rs b/coffee_lib/src/plugin_conf.rs index 3cb14969..330de0a7 100644 --- a/coffee_lib/src/plugin_conf.rs +++ b/coffee_lib/src/plugin_conf.rs @@ -2,30 +2,31 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] - pub struct Conf { - pub plugin: Plugin, + pub plugin: Option, + pub bin: Option, } #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] - pub struct Plugin { pub name: String, pub version: String, pub lang: String, - pub deprecated: Option<()>, + pub deprecated: Option, pub dependencies: Option>, pub install: Option, pub main: String, } -#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] pub struct Deprecaterd { pub reason: String, } -#[cfg(test)] -mod tests { - #[test] - fn test_remote() {} +#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] +pub struct Binary { + pub name: String, + pub deprecated: Option, + pub dependencies: Option>, + pub install: Option, }