Mountain/RPC/CocoonService/GenericRequest/Commands/
ExecuteCommand.rs1#![allow(unused_variables, dead_code, unused_imports)]
2
3use serde_json::{Value, json};
4use tonic::Response;
5use CommonLibrary::Command::CommandExecutor::CommandExecutor;
6
7use crate::{Environment::MountainEnvironment::MountainEnvironment, Vine::Generated::GenericResponse};
8
9pub async fn Fn(RequestId:u64, Params:Value, Env:&MountainEnvironment) -> Response<GenericResponse> {
10 let CommandId = Params.get("commandId").and_then(|V| V.as_str()).unwrap_or("").to_string();
11
12 let Arg = Params
13 .get("arguments")
14 .and_then(|A| A.as_array())
15 .and_then(|A| A.first())
16 .cloned()
17 .unwrap_or(Value::Null);
18
19 match Env.ExecuteCommand(CommandId, Arg).await {
20 Ok(V) => super::super::FileSystem::OkResponse(RequestId, &json!({ "result": V })),
21
22 Err(Error) => super::super::FileSystem::ErrResponse(RequestId, -32000, Error.to_string()),
23 }
24}