pub enum MenuAction {
Command(String),
Remote(String),
SubMenu(Vec<MenuItem>),
}Expand description
Action to perform when a menu item is selected
Menu actions define what happens when a user interacts with a menu item. They can execute terminal commands, trigger plugin callbacks, or open submenus.
Variants§
Command(String)
Execute a terminal command
When selected, this action sends the command to the active PTY. The command is executed as if the user typed it into the terminal.
§Example
use scarab_plugin_api::menu::MenuAction;
let action = MenuAction::Command("ls -la".to_string());Remote(String)
Trigger a plugin remote action
When selected, this action calls the plugin’s on_remote_command hook
with the specified identifier. This allows plugins to implement custom
actions beyond simple command execution.
§Example
use scarab_plugin_api::menu::MenuAction;
// Will call on_remote_command("refresh_cache", ctx)
let action = MenuAction::Remote("refresh_cache".to_string());SubMenu(Vec<MenuItem>)
Open a submenu with additional items
When selected, this action displays a nested menu with the provided items. Submenus can be nested arbitrarily deep, but keep hierarchies shallow for better user experience (2-3 levels maximum recommended).
§Example
use scarab_plugin_api::menu::{MenuItem, MenuAction};
let submenu = MenuAction::SubMenu(vec![
MenuItem::new("Option 1", MenuAction::Command("cmd1".to_string())),
MenuItem::new("Option 2", MenuAction::Command("cmd2".to_string())),
]);Implementations§
Source§impl MenuAction
impl MenuAction
Sourcepub fn is_command(&self) -> bool
pub fn is_command(&self) -> bool
Check if this action executes a command
§Returns
true if this action executes a terminal command, false otherwise
Trait Implementations§
Source§impl Clone for MenuAction
impl Clone for MenuAction
Source§fn clone(&self) -> MenuAction
fn clone(&self) -> MenuAction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more