From bdc189e32e7c9dd61811fe17e50ac171ca94c647 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sat, 30 May 2026 23:58:02 +0300 Subject: feat: support custom command descriptions refs #362 --- src/config/keybinds.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/config') diff --git a/src/config/keybinds.rs b/src/config/keybinds.rs index 401154bc..6ae8c4a1 100644 --- a/src/config/keybinds.rs +++ b/src/config/keybinds.rs @@ -63,6 +63,8 @@ pub struct CommandKeybindConfig { /// Command execution mode. Default: "shell". #[serde(rename = "type")] pub action_type: CommandKeybindType, + /// Optional user-defined description for this custom command. + pub description: Option, } impl Default for CommandKeybindConfig { @@ -71,6 +73,7 @@ impl Default for CommandKeybindConfig { key: BindingConfig::empty(), command: String::new(), action_type: CommandKeybindType::Shell, + description: None, } } } @@ -238,6 +241,7 @@ pub struct CustomCommandKeybind { pub label: String, pub command: String, pub action: CustomCommandAction, + pub description: Option, } /// Parsed keybinds for Herdr actions. @@ -536,6 +540,7 @@ impl Config { label, command: command.command.clone(), action, + description: command.description.clone(), }); } @@ -1668,4 +1673,23 @@ new_workspace = "prefix+n" diag.contains("kept keys.new_workspace") && diag.contains("disabled keys.next_tab") })); } + + #[test] + fn custom_command_with_description_parses() { + let config: Config = toml::from_str( + r#" +[[keys.command]] +key = "prefix+y" +command = "echo hello" +description = "say hello" +"#, + ) + .unwrap(); + let keybinds = config.keybinds(); + assert_eq!(keybinds.custom_commands.len(), 1); + assert_eq!( + keybinds.custom_commands[0].description, + Some("say hello".to_string()) + ); + } } -- cgit v1.2.3