diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-30 23:58:02 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-31 00:02:08 +0300 |
| commit | bdc189e32e7c9dd61811fe17e50ac171ca94c647 (patch) | |
| tree | 730e0e14d571e9bb693ad583b02e24622e4258d4 /src/config | |
| parent | fc4e1bbf6b0fa2ec37445a5b72356514c7c6be6a (diff) | |
feat: support custom command descriptions
refs #362
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/keybinds.rs | 24 |
1 files changed, 24 insertions, 0 deletions
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<String>, } 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<String>, } /// 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()) + ); + } } |
