Mountain/RPC/CocoonService/Command/
RegisterCommand.rs1use CommonLibrary::Command::CommandExecutor::CommandExecutor;
5use tonic::{Response, Status};
6use ::Vine::Generated::{Empty, RegisterCommandRequest};
7
8use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
9
10pub async fn Fn(Service:&CocoonServiceImpl, Request:RegisterCommandRequest) -> Result<Response<Empty>, Status> {
11 dev_log!(
12 "cocoon",
13 "[CocoonService] Registering command '{}' from extension '{}'",
14 Request.command_id,
15 Request.extension_id
16 );
17
18 if let Err(Error) = Service
19 .environment
20 .RegisterCommand(Request.extension_id.clone(), Request.command_id.clone())
21 .await
22 {
23 dev_log!(
24 "cocoon",
25 "warn: [CocoonService] Failed to register command '{}': {:?}",
26 Request.command_id,
27 Error
28 );
29 } else {
30 dev_log!(
31 "cocoon",
32 "[CocoonService] Command registered: id={}, title={:?}",
33 Request.command_id,
34 Request.title
35 );
36 }
37
38 Ok(Response::new(Empty {}))
39}