feat: v1.4.4, support config environment

This commit is contained in:
2023-12-10 13:01:10 +08:00
parent 7ee38b8ac5
commit 880b5be94e
3 changed files with 12 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -1700,7 +1700,7 @@ dependencies = [
[[package]]
name = "tiny-encrypt"
version = "1.4.3"
version = "1.4.4"
dependencies = [
"aes-gcm-stream",
"base64",

View File

@@ -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"

View File

@@ -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<HashMap<String, String>>,
pub envelops: Vec<TinyEncryptConfigEnvelop>,
pub profiles: HashMap<String, Vec<String>>,
}
@@ -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)
}