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]]
|
[[package]]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.4.0"
|
version = "1.4.1"
|
||||||
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.0"
|
version = "1.4.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "A simple and tiny file encrypt tool"
|
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 {
|
for envelop in envelops {
|
||||||
config_envelops.push(ConfigEnvelop {
|
config_envelops.push(ConfigEnvelop {
|
||||||
r#type: envelop.r#type.get_name().to_string(),
|
r#type: envelop.r#type.get_name().to_string(),
|
||||||
sid: envelop.sid.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()),
|
sid: strip_field(&envelop.sid.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()), 25),
|
||||||
kid: process_kid(&envelop.kid),
|
kid: strip_field(&envelop.kid, 40),
|
||||||
desc: envelop.desc.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()),
|
desc: strip_field(&envelop.desc.as_ref().map(ToString::to_string).unwrap_or_else(|| "-".to_string()), 40),
|
||||||
args: envelop.args.as_ref().map(|a| format!("[{}]", a.join(", "))).unwrap_or_else(|| "-".to_string()),
|
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);
|
let mut table = Table::new(config_envelops);
|
||||||
@@ -85,13 +85,13 @@ fn config_key_filter(cmd_version: &CmdConfig, config: &TinyEncryptConfig) -> XRe
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_kid(kid: &str) -> String {
|
fn strip_field(kid: &str, max_len: usize) -> String {
|
||||||
if kid.len() < 10 {
|
if kid.len() <= max_len {
|
||||||
kid.to_string()
|
kid.to_string()
|
||||||
} else {
|
} else {
|
||||||
kid.chars().enumerate()
|
kid.chars().enumerate()
|
||||||
.filter(|(i, _c)| *i <= 50)
|
.filter(|(i, _c)| *i < max_len)
|
||||||
.map(|(i, c)| iff!(i >= 48, '.', c)).collect()
|
.map(|(i, c)| iff!(i >= (max_len - 3), '.', c)).collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user