1
0
Fork 0

Run command from args params

This commit is contained in:
Florian RICHER 2023-01-30 22:31:42 +01:00
parent 5ddb43351b
commit 3279fb22cd
2 changed files with 13 additions and 2 deletions

View file

@ -7,6 +7,14 @@ use libcommand::internal::{AuthorizeRequest};
#[cfg(unix)]
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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::<libcommand::Command>(&arg)
.unwrap()
.into();
let mut client = client::connect().await?;
let request = tonic::Request::new(AuthorizeRequest {
@ -18,6 +26,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("RESPONSE={:?}", response);
let mut child = command.spawn().unwrap();
child.wait().unwrap();
Ok(())
}

View file

@ -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
};