From 66eeb4d0e2fc8aea04e637a6c34bd45f5e25ff71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Wed, 28 Aug 2024 11:49:44 +0200 Subject: [PATCH] Parse json args as vector of strings. This is breaking change of CLI, but resolves all the issues with passing args. --- crates/cli/src/lib.rs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 49dc6ff..fa89867 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -27,22 +27,10 @@ pub async fn calculate_hash_command(file_path: &PathBuf) -> BoxResult { .to_string()) } -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct JsonCmdArgs { - pub name: String, - pub value: String, -} - -impl From for [String; 2] { - fn from(args: JsonCmdArgs) -> Self { - [args.name, args.value] - } -} - #[derive(Serialize, Deserialize, Debug, Clone)] pub struct JsonExecArgs { pub program: String, - pub cmd_args: Vec, + pub cmd_args: Vec, pub inputs: Vec, } @@ -131,12 +119,7 @@ pub async fn run_exec_command( program: (&(hex::decode(args.program) .map_err(|err| format!("program decoding hash error:{err}"))?)[..]) .into(), - args: args - .cmd_args - .into_iter() - .flat_map(<[String; 2]>::from) - .filter(|x| !x.is_empty()) - .collect(), + args: args.cmd_args, inputs: input_data, };