aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/plugin_api/plugin_command.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-12-01 11:06:44 +0100
committerGitHub <noreply@github.com>2024-12-01 11:06:44 +0100
commit0c21eae6646d511944a85121433b9443a96c73aa (patch)
treea5a091a4df73920dfbb03e2abfb1cb770ffbf44b /zellij-utils/src/plugin_api/plugin_command.rs
parentdocs(changelog): ui component padding (diff)
downloadsl0ppij-0c21eae6646d511944a85121433b9443a96c73aa.tar.gz
sl0ppij-0c21eae6646d511944a85121433b9443a96c73aa.tar.xz
sl0ppij-0c21eae6646d511944a85121433b9443a96c73aa.zip
feat(plugins): allow changing the plugin's `/host` folder (under a new permission) (#3827)
* working without notifying plugins * permissions and events * cleanups and formatting * style(fmt): rustfmt
Diffstat (limited to 'zellij-utils/src/plugin_api/plugin_command.rs')
-rw-r--r--zellij-utils/src/plugin_api/plugin_command.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/zellij-utils/src/plugin_api/plugin_command.rs b/zellij-utils/src/plugin_api/plugin_command.rs
index 06687971..4317a02e 100644
--- a/zellij-utils/src/plugin_api/plugin_command.rs
+++ b/zellij-utils/src/plugin_api/plugin_command.rs
@@ -4,9 +4,9 @@ pub use super::generated_api::api::{
input_mode::InputMode as ProtobufInputMode,
plugin_command::{
plugin_command::Payload, BreakPanesToNewTabPayload, BreakPanesToTabWithIndexPayload,
- ClearScreenForPaneIdPayload, CliPipeOutputPayload, CloseTabWithIndexPayload, CommandName,
- ContextItem, EditScrollbackForPaneWithIdPayload, EnvVariable, ExecCmdPayload,
- FixedOrPercent as ProtobufFixedOrPercent,
+ ChangeHostFolderPayload, ClearScreenForPaneIdPayload, CliPipeOutputPayload,
+ CloseTabWithIndexPayload, CommandName, ContextItem, EditScrollbackForPaneWithIdPayload,
+ EnvVariable, ExecCmdPayload, FixedOrPercent as ProtobufFixedOrPercent,
FixedOrPercentValue as ProtobufFixedOrPercentValue,
FloatingPaneCoordinates as ProtobufFloatingPaneCoordinates, HidePaneWithIdPayload,
HttpVerb as ProtobufHttpVerb, IdAndNewName, KeyToRebind, KeyToUnbind, KillSessionsPayload,
@@ -1303,6 +1303,14 @@ impl TryFrom<ProtobufPluginCommand> for PluginCommand {
Some(_) => Err("ListClients should have no payload, found a payload"),
None => Ok(PluginCommand::ListClients),
},
+ Some(CommandName::ChangeHostFolder) => match protobuf_plugin_command.payload {
+ Some(Payload::ChangeHostFolderPayload(change_host_folder_payload)) => {
+ Ok(PluginCommand::ChangeHostFolder(PathBuf::from(
+ change_host_folder_payload.new_host_folder,
+ )))
+ },
+ _ => Err("Mismatched payload for ChangeHostFolder"),
+ },
None => Err("Unrecognized plugin command"),
}
}
@@ -2130,6 +2138,12 @@ impl TryFrom<PluginCommand> for ProtobufPluginCommand {
name: CommandName::ListClients as i32,
payload: None,
}),
+ PluginCommand::ChangeHostFolder(new_host_folder) => Ok(ProtobufPluginCommand {
+ name: CommandName::ChangeHostFolder as i32,
+ payload: Some(Payload::ChangeHostFolderPayload(ChangeHostFolderPayload {
+ new_host_folder: new_host_folder.display().to_string(), // TODO: not accurate?
+ })),
+ }),
}
}
}