Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Parse json args as vector of strings #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,10 @@ pub async fn calculate_hash_command(file_path: &PathBuf) -> BoxResult<String> {
.to_string())
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct JsonCmdArgs {
pub name: String,
pub value: String,
}

impl From<JsonCmdArgs> 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<JsonCmdArgs>,
pub cmd_args: Vec<String>,
pub inputs: Vec<JsonProgramData>,
}

Expand Down Expand Up @@ -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,
};

Expand Down
Loading