feat: v1.4.1, optimize config outputs
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1700,7 +1700,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tiny-encrypt"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
dependencies = [
|
||||
"aes-gcm-stream",
|
||||
"base64",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tiny-encrypt"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "A simple and tiny file encrypt tool"
|
||||
|
||||
@@ -73,10 +73,10 @@ fn config_key_filter(cmd_version: &CmdConfig, config: &TinyEncryptConfig) -> XRe
|
||||
for envelop in envelops {
|
||||
config_envelops.push(ConfigEnvelop {
|
||||
r#type: envelop.r#type.get_name().to_string(),
|
||||
sid: envelop.sid.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()),
|
||||
kid: process_kid(&envelop.kid),
|
||||
desc: envelop.desc.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()),
|
||||
args: envelop.args.as_ref().map(|a| format!("[{}]", a.join(", "))).unwrap_or_else(|| "-".to_string()),
|
||||
sid: strip_field(&envelop.sid.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()), 25),
|
||||
kid: strip_field(&envelop.kid, 40),
|
||||
desc: strip_field(&envelop.desc.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()), 40),
|
||||
args: strip_field(&envelop.args.as_ref().map(|a| format!("[{}]", a.join(", "))).unwrap_or_else(|| "-".to_string()), 20),
|
||||
});
|
||||
}
|
||||
let mut table = Table::new(config_envelops);
|
||||
@@ -85,13 +85,13 @@ fn config_key_filter(cmd_version: &CmdConfig, config: &TinyEncryptConfig) -> XRe
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn process_kid(kid: &str) -> String {
|
||||
if kid.len() < 10 {
|
||||
fn strip_field(kid: &str, max_len: usize) -> String {
|
||||
if kid.len() <= max_len {
|
||||
kid.to_string()
|
||||
} else {
|
||||
kid.chars().enumerate()
|
||||
.filter(|(i, _c)| *i <= 50)
|
||||
.map(|(i, c)| iff!(i >= 48, '.', c)).collect()
|
||||
.filter(|(i, _c)| *i < max_len)
|
||||
.map(|(i, c)| iff!(i >= (max_len - 3), '.', c)).collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user