diff --git a/Cargo.lock b/Cargo.lock index d2c9e1f..26326c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1700,7 +1700,7 @@ dependencies = [ [[package]] name = "tiny-encrypt" -version = "1.4.3" +version = "1.4.4" dependencies = [ "aes-gcm-stream", "base64", diff --git a/Cargo.toml b/Cargo.toml index 3873a75..0420b8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tiny-encrypt" -version = "1.4.3" +version = "1.4.4" edition = "2021" license = "MIT" description = "A simple and tiny file encrypt tool" diff --git a/src/config.rs b/src/config.rs index 8c3b508..27e4547 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,6 @@ use std::cmp::Ordering; use std::collections::HashMap; -use std::fs; +use std::{env, fs}; use rust_util::{debugging, opt_result, simple_error, XResult}; use rust_util::util_file::resolve_file_path; @@ -34,6 +34,7 @@ use crate::spec::TinyEncryptEnvelopType; #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct TinyEncryptConfig { + pub environment: Option>, pub envelops: Vec, pub profiles: HashMap>, } @@ -74,6 +75,14 @@ impl TinyEncryptConfig { } } config.profiles = splited_profiles; + + if let Some(environment) = &config.environment { + for (k, v) in environment { + debugging!("Set env: {}={}", k, v); + env::set_var(k, v); + } + } + Ok(config) }