From 3279fb22cdc3f9d4c2dd01294fb7a2c5cb152a49 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Mon, 30 Jan 2023 22:31:42 +0100 Subject: [PATCH] Run command from args params --- src/client/main.rs | 11 +++++++++++ src/daemon/server.rs | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/client/main.rs b/src/client/main.rs index 7631fd8..3496218 100644 --- a/src/client/main.rs +++ b/src/client/main.rs @@ -7,6 +7,14 @@ use libcommand::internal::{AuthorizeRequest}; #[cfg(unix)] #[tokio::main] async fn main() -> Result<(), Box> { + // let arg = std::env::args() + // .skip(1) + // .next().unwrap(); + let arg = String::from("{\"command\": \"nu\", \"envs\": {}, \"args\": []}"); + let mut command : std::process::Command = serde_json::from_str::(&arg) + .unwrap() + .into(); + let mut client = client::connect().await?; let request = tonic::Request::new(AuthorizeRequest { @@ -18,6 +26,9 @@ async fn main() -> Result<(), Box> { println!("RESPONSE={:?}", response); + let mut child = command.spawn().unwrap(); + child.wait().unwrap(); + Ok(()) } diff --git a/src/daemon/server.rs b/src/daemon/server.rs index 8f44975..ba55f95 100644 --- a/src/daemon/server.rs +++ b/src/daemon/server.rs @@ -2,10 +2,10 @@ #[cfg(unix)] use tonic::transport::server::UdsConnectInfo; -use tonic::{transport::Server, Request, Response, Status}; +use tonic::{Request, Response, Status}; use libcommand::internal::{ - unix_server::{Unix, UnixServer}, + unix_server::Unix, AuthorizeRequest, AuthorizeResponse, TerminateRequest, TerminateResponse };