feat: v1.4.4, support config environment
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1700,7 +1700,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.4.3"
|
version = "1.4.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm-stream",
|
"aes-gcm-stream",
|
||||||
"base64",
|
"base64",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.4.3"
|
version = "1.4.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "A simple and tiny file encrypt tool"
|
description = "A simple and tiny file encrypt tool"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs;
|
use std::{env, fs};
|
||||||
|
|
||||||
use rust_util::{debugging, opt_result, simple_error, XResult};
|
use rust_util::{debugging, opt_result, simple_error, XResult};
|
||||||
use rust_util::util_file::resolve_file_path;
|
use rust_util::util_file::resolve_file_path;
|
||||||
@@ -34,6 +34,7 @@ use crate::spec::TinyEncryptEnvelopType;
|
|||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct TinyEncryptConfig {
|
pub struct TinyEncryptConfig {
|
||||||
|
pub environment: Option<HashMap<String, String>>,
|
||||||
pub envelops: Vec<TinyEncryptConfigEnvelop>,
|
pub envelops: Vec<TinyEncryptConfigEnvelop>,
|
||||||
pub profiles: HashMap<String, Vec<String>>,
|
pub profiles: HashMap<String, Vec<String>>,
|
||||||
}
|
}
|
||||||
@@ -74,6 +75,14 @@ impl TinyEncryptConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
config.profiles = splited_profiles;
|
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)
|
Ok(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user