DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/UI/KeybindingAdd.rs
1//! Wire method: `keybinding:add`.
2
3use std::sync::Arc;
4
5use serde_json::Value;
6
7use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
8
9pub async fn Fn(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
10 let CommandId = Arguments
11 .first()
12 .and_then(|V| V.as_str())
13 .ok_or("keybinding:add requires commandId".to_string())?
14 .to_owned();
15
16 let KeyExpression = Arguments
17 .get(1)
18 .and_then(|V| V.as_str())
19 .ok_or("keybinding:add requires keybinding".to_string())?
20 .to_owned();
21
22 let When = Arguments.get(2).and_then(|V| V.as_str()).map(str::to_owned);
23
24 RunTime
25 .Environment
26 .ApplicationState
27 .Feature
28 .Keybindings
29 .AddKeybinding(CommandId, KeyExpression, When);
30
31 Ok(Value::Null)
32}