Skip to content

Commit ed48a27

Browse files
feat(lib): add support for binary configuration
The tool for core lightning are not all plugin, but they can be just binary like the coffee one. So, this will start to support inside the configuration, the possibility to support binaries installation and tracking. So, a repository can have also custom binaries, like coffee or core lightning itself. Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent ee264b2 commit ed48a27

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

coffee_github/src/repository.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,15 @@ impl Github {
101101

102102
let conf_file = serde_yaml::from_str::<Conf>(&conf_str)
103103
.map_err(|err| error!("Coffee manifest malformed: {err}"))?;
104-
plugin_name = Some(conf_file.plugin.name.to_string());
105-
let conf_lang = conf_file.plugin.lang.to_owned();
104+
105+
let Some(ref plugin) = conf_file.plugin else {
106+
// FIXME: read the binary information and store it anywhere
107+
break;
108+
};
109+
110+
plugin_name = Some(plugin.name.to_string());
111+
let conf_lang = plugin.lang.to_owned();
112+
106113
match conf_lang.as_str() {
107114
"pypip" => plugin_lang = PluginLang::PyPip,
108115
"pypoetry" => plugin_lang = PluginLang::PyPoetry,
@@ -117,7 +124,7 @@ impl Github {
117124
}
118125
};
119126

120-
exec_path = Some(format!("{root_path}/{}", conf_file.plugin.main));
127+
exec_path = Some(format!("{root_path}/{}", plugin.main));
121128
conf = Some(conf_file);
122129
break;
123130
}

coffee_lib/src/plugin.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ impl Plugin {
132132
pub async fn configure(&mut self, verbose: bool) -> Result<String, CoffeeError> {
133133
log::debug!("install plugin inside from root dir {}", self.root_path);
134134
let exec_path = if let Some(conf) = &self.conf {
135-
if let Some(script) = &conf.plugin.install {
135+
let Some(ref plugin) = conf.plugin else {
136+
return Err(error!("plugin {self} is not a plugin"));
137+
};
138+
if let Some(script) = &plugin.install {
136139
sh!(self.root_path.clone(), script, verbose);
137140
self.exec_path.clone()
138141
} else {

coffee_lib/src/plugin_conf.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@
22
use serde::{Deserialize, Serialize};
33

44
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
5-
65
pub struct Conf {
7-
pub plugin: Plugin,
6+
pub plugin: Option<Plugin>,
7+
pub bin: Option<Binary>,
88
}
99

1010
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
11-
1211
pub struct Plugin {
1312
pub name: String,
1413
pub version: String,
1514
pub lang: String,
16-
pub deprecated: Option<()>,
15+
pub deprecated: Option<Deprecaterd>,
1716
pub dependencies: Option<Vec<String>>,
1817
pub install: Option<String>,
1918
pub main: String,
2019
}
2120

22-
#[derive(Debug, PartialEq, Serialize, Deserialize)]
21+
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
2322
pub struct Deprecaterd {
2423
pub reason: String,
2524
}
2625

27-
#[cfg(test)]
28-
mod tests {
29-
#[test]
30-
fn test_remote() {}
26+
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
27+
pub struct Binary {
28+
pub name: String,
29+
pub deprecated: Option<Deprecaterd>,
30+
pub dependencies: Option<Vec<String>>,
31+
pub install: Option<String>,
3132
}

0 commit comments

Comments
 (0)