From c316d30af44a54119a168967d591b0e8ec4d54c3 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Fri, 31 Jan 2025 10:13:28 +0200 Subject: feat(zkvms_host_io): Add default_env RunWith attribute --- zkvms_host_io/Cargo.toml | 1 + zkvms_host_io/src/lib.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/zkvms_host_io/Cargo.toml b/zkvms_host_io/Cargo.toml index 371758e..46725df 100644 --- a/zkvms_host_io/Cargo.toml +++ b/zkvms_host_io/Cargo.toml @@ -9,3 +9,4 @@ clap = { version = "4.5.26", features = ["derive"] } num-traits = "0.2.19" serde = { version = "1.0.217", features = ["derive"] } toml = "0.8.19" +env-file-reader = "0.3.0" diff --git a/zkvms_host_io/src/lib.rs b/zkvms_host_io/src/lib.rs index 191d2ad..a3bdb1b 100644 --- a/zkvms_host_io/src/lib.rs +++ b/zkvms_host_io/src/lib.rs @@ -1,10 +1,12 @@ use clap::{Parser, ValueEnum}; use num_traits::NumCast; use serde::{ Serialize, Deserialize }; -use std::fs::read_to_string; +use env_file_reader::read_str; +use std::{ fs::read_to_string, collections::HashMap }; pub use input_macros::foreach_input_field; static DEFAULT_PUBLIC_INPUT: &str = include_str!(concat!(env!("INPUTS_DIR"), "/default_public_input.toml")); +static DEFAULT_ENV: &str = include_str!(concat!(env!("INPUTS_DIR"), "/default.env")); #[derive(Parser, Debug)] #[command(version, about, long_about = None)] @@ -22,10 +24,11 @@ pub enum RunType { Verify, } -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct RunWith { pub run_type: RunType, pub input: T, + pub default_env: HashMap, } input_macros::generate_input_struct!(); @@ -38,10 +41,13 @@ pub fn read_args() -> RunWith { } else { DEFAULT_PUBLIC_INPUT.to_string() }; - let val: Input = toml::from_str(&contents).unwrap(); + let input: Input = toml::from_str(&contents).unwrap(); + + let default_env = read_str(DEFAULT_ENV).unwrap(); RunWith { run_type: cli.run_type, - input: val, + input, + default_env, } } -- cgit v1.2.3