aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/input/layout.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-07-25 10:04:12 +0200
committerGitHub <noreply@github.com>2023-07-25 10:04:12 +0200
commitc95d0e769f31b21f5e2d4aaf6465468344f1bfd6 (patch)
tree9589f0875b91b73460b807e90817907bf3d7d8c6 /zellij-utils/src/input/layout.rs
parentdocs(changelog): generate session names with custom words list (diff)
downloadsl0ppij-c95d0e769f31b21f5e2d4aaf6465468344f1bfd6.tar.gz
sl0ppij-c95d0e769f31b21f5e2d4aaf6465468344f1bfd6.tar.xz
sl0ppij-c95d0e769f31b21f5e2d4aaf6465468344f1bfd6.zip
feat(plugins): make plugins configurable (#2646)
* work * make every plugin entry point configurable * make integration tests pass * make e2e tests pass * add test for plugin configuration * add test snapshot * add plugin config parsing test * cleanups * style(fmt): rustfmt * style(comment): remove commented code
Diffstat (limited to 'zellij-utils/src/input/layout.rs')
-rw-r--r--zellij-utils/src/input/layout.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs
index c1d95a12..55e5fc69 100644
--- a/zellij-utils/src/input/layout.rs
+++ b/zellij-utils/src/input/layout.rs
@@ -212,6 +212,35 @@ pub struct RunPlugin {
#[serde(default)]
pub _allow_exec_host_cmd: bool,
pub location: RunPluginLocation,
+ pub configuration: PluginUserConfiguration,
+}
+
+#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
+pub struct PluginUserConfiguration(BTreeMap<String, String>);
+
+impl PluginUserConfiguration {
+ pub fn new(configuration: BTreeMap<String, String>) -> Self {
+ PluginUserConfiguration(configuration)
+ }
+ pub fn inner(&self) -> &BTreeMap<String, String> {
+ &self.0
+ }
+}
+
+impl FromStr for PluginUserConfiguration {
+ type Err = &'static str;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ let mut ret = BTreeMap::new();
+ let configs = s.split(',');
+ for config in configs {
+ let mut config = config.split('=');
+ let key = config.next().ok_or("invalid configuration key")?.to_owned();
+ let value = config.map(|c| c.to_owned()).collect::<Vec<_>>().join("=");
+ ret.insert(key, value);
+ }
+ Ok(PluginUserConfiguration(ret))
+ }
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]