Add shortcut profile import export

This commit is contained in:
2026-05-09 01:30:20 -04:00
parent d193f5a400
commit fb6677aec2
7 changed files with 759 additions and 156 deletions
+34 -1
View File
@@ -11,6 +11,12 @@ enum SpaceFileCommand {
ImportPreservingProfiles,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum ShortcutFileCommand {
Export,
Import,
}
impl ElyShell {
pub(super) fn handle_shell_command_intent(
&mut self,
@@ -36,6 +42,12 @@ impl ElyShell {
}
None => {}
}
match shortcut_file_command(command) {
Some(ShortcutFileCommand::Export) => self.export_shortcuts(window, cx),
Some(ShortcutFileCommand::Import) => self.choose_shortcut_import(window, cx),
None => {}
}
}
}
@@ -66,9 +78,24 @@ fn space_file_command(command: &str) -> Option<SpaceFileCommand> {
}
}
fn shortcut_file_command(command: &str) -> Option<ShortcutFileCommand> {
match command.trim().to_ascii_lowercase().as_str() {
"export-shortcuts" | "export shortcuts" | "export-keybindings" | "export keybindings" => {
Some(ShortcutFileCommand::Export)
}
"import-shortcuts" | "import shortcuts" | "import-keybindings" | "import keybindings" => {
Some(ShortcutFileCommand::Import)
}
_ => None,
}
}
#[cfg(test)]
mod tests {
use super::{SpaceFileCommand, install_plugin_from_file_command, space_file_command};
use super::{
ShortcutFileCommand, SpaceFileCommand, install_plugin_from_file_command,
shortcut_file_command, space_file_command,
};
#[test]
fn install_plugin_from_file_command_matches_prd_aliases() {
@@ -101,4 +128,10 @@ mod tests {
assert_eq!(space_file_command("new-space Research"), None);
assert_eq!(space_file_command("spaces"), None);
}
#[test]
fn shortcut_file_command_matches_export_and_import_aliases() {
assert_eq!(shortcut_file_command("export-shortcuts"), Some(ShortcutFileCommand::Export));
assert_eq!(shortcut_file_command("import keybindings"), Some(ShortcutFileCommand::Import));
}
}