DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/UI/
QuickInputShowInputBox.rs1use std::sync::Arc;
4
5use serde_json::{Value, json};
6
7use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
8
9pub async fn Fn(RunTime:Arc<ApplicationRunTime>, Arguments:Vec<Value>) -> Result<Value, String> {
10 use CommonLibrary::UserInterface::{
11 DTO::InputBoxOptionsDTO::InputBoxOptionsDTO,
12 UserInterfaceProvider::UserInterfaceProvider,
13 };
14
15 let Opts = Arguments.first();
16
17 let Options = InputBoxOptionsDTO {
18 Prompt:Opts
19 .and_then(|V| V.get("prompt"))
20 .and_then(|P| P.as_str())
21 .map(|S| S.to_string()),
22
23 PlaceHolder:Opts
24 .and_then(|V| V.get("placeholder"))
25 .and_then(|P| P.as_str())
26 .map(|S| S.to_string()),
27
28 IsPassword:Some(Opts.and_then(|V| V.get("password")).and_then(|B| B.as_bool()).unwrap_or(false)),
29
30 Value:Opts
31 .and_then(|V| V.get("value"))
32 .and_then(|V| V.as_str())
33 .map(|S| S.to_string()),
34
35 Title:Opts
36 .and_then(|V| V.get("title"))
37 .and_then(|T| T.as_str())
38 .map(|S| S.to_string()),
39
40 IgnoreFocusOut:None,
41 };
42
43 let Result = RunTime
44 .Environment
45 .ShowInputBox(Some(Options))
46 .await
47 .map_err(|Error| format!("quickInput:showInputBox failed: {}", Error))?;
48
49 Ok(Result.map(|S| json!(S)).unwrap_or(Value::Null))
50}