feat: update command info
This commit is contained in:
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -1100,6 +1100,12 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quick-error"
|
||||||
|
version = "1.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "0.3.15"
|
version = "0.3.15"
|
||||||
@@ -1404,6 +1410,16 @@ dependencies = [
|
|||||||
"opaque-debug",
|
"opaque-debug",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "simpledateformat"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cd2436140481bbe945c4d6deab521cf1ac52d73766e3c5d28d2c65e2635ae115"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"quick-error",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.7"
|
version = "0.4.7"
|
||||||
@@ -1554,6 +1570,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm",
|
"aes-gcm",
|
||||||
"base64",
|
"base64",
|
||||||
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"hex",
|
"hex",
|
||||||
"openpgp-card",
|
"openpgp-card",
|
||||||
@@ -1562,6 +1579,7 @@ dependencies = [
|
|||||||
"rust_util",
|
"rust_util",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"simpledateformat",
|
||||||
"yubico_manager",
|
"yubico_manager",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ description = "A simple and tiny file encrypt tool"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
aes-gcm = { version = "0.10.1", features = ["zeroize"] }
|
aes-gcm = { version = "0.10.1", features = ["zeroize"] }
|
||||||
base64 = "0.21.0"
|
base64 = "0.21.0"
|
||||||
|
chrono = "0.4.23"
|
||||||
clap = { version = "4.1.4", features = ["derive"] }
|
clap = { version = "4.1.4", features = ["derive"] }
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
openpgp-card = "0.3.3"
|
openpgp-card = "0.3.3"
|
||||||
@@ -18,6 +19,7 @@ reqwest = { version = "0.11.14", features = ["blocking", "rustls", "rustls-tls"]
|
|||||||
rust_util = "0.6.41"
|
rust_util = "0.6.41"
|
||||||
serde = { version = "1.0.152", features = ["derive"] }
|
serde = { version = "1.0.152", features = ["derive"] }
|
||||||
serde_json = "1.0.93"
|
serde_json = "1.0.93"
|
||||||
|
simpledateformat = "0.1.3"
|
||||||
yubico_manager = "0.9.0"
|
yubico_manager = "0.9.0"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use base64::engine::general_purpose;
|
use base64::engine::general_purpose;
|
||||||
use openpgp_card::crypto_data::Cryptogram;
|
use openpgp_card::crypto_data::Cryptogram;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
use std::cmp::max;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
use std::ops::Add;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::time::{Duration, SystemTime};
|
||||||
use rust_util::{information, opt_result, simple_error, XResult};
|
use rust_util::{information, opt_result, simple_error, XResult};
|
||||||
use crate::file;
|
use crate::file;
|
||||||
|
|
||||||
@@ -10,24 +13,43 @@ pub fn info(path: PathBuf) -> XResult<()> {
|
|||||||
|
|
||||||
let mut infos = vec![];
|
let mut infos = vec![];
|
||||||
infos.push("Tiny Encrypt File Info".to_string());
|
infos.push("Tiny Encrypt File Info".to_string());
|
||||||
infos.push(format!("File..............: {}", path_display));
|
let compressed = if meta.compress { " [compressed]" } else { "" };
|
||||||
infos.push(format!("File size.........: {} bytes", meta.file_length));
|
infos.push(format!("{}: {}{}", header("File"), path_display, compressed));
|
||||||
infos.push(format!("Enc file summary..: Version: {}, Agent: {}", meta.version, meta.user_agent));
|
infos.push(format!("{}: {} bytes", header("File size"), meta.file_length));
|
||||||
infos.push(format!("Last modified.....: {}", meta.file_last_modified));
|
infos.push(format!("{}: Version: {}, Agent: {}",
|
||||||
infos.push(format!("Enc file created..: {}", meta.created));
|
header("Enc file summary"), meta.version, meta.user_agent)
|
||||||
infos.push(format!("Envelops..........: KMS: {}, PGP: {}",
|
);
|
||||||
|
|
||||||
|
let fmt = simpledateformat::fmt("EEE MMM dd HH:MM:ss z yyyy").unwrap();
|
||||||
|
infos.push(format!("{}: {}", header("Last modified"), fmt.format_local(from_unix_epoch(meta.file_last_modified))));
|
||||||
|
infos.push(format!("{}: {}", header("Enc file created"), fmt.format_local(from_unix_epoch(meta.created))));
|
||||||
|
|
||||||
|
infos.push(format!("{}: KMS: {}, PGP: {}",
|
||||||
|
header("Envelops"),
|
||||||
to_yes_or_no(&meta.envelop),
|
to_yes_or_no(&meta.envelop),
|
||||||
to_yes_or_no(&meta.pgp_envelop)
|
to_yes_or_no(&meta.pgp_envelop)
|
||||||
));
|
));
|
||||||
meta.pgp_fingerprint.map(|fingerprint| {
|
meta.pgp_fingerprint.map(|fingerprint| {
|
||||||
infos.push(format!("PGP fingerprint...: {}", fingerprint));
|
infos.push(format!("{}: {}", header("PGP fingerprint"), fingerprint));
|
||||||
});
|
});
|
||||||
infos.push(format!("Encrypted comment.: {}", to_yes_or_no(&meta.encrypted_comment)));
|
meta.comment.map(|comment| {
|
||||||
|
infos.push(format!("{}: {}", header("Comment"), comment));
|
||||||
|
});
|
||||||
|
infos.push(format!("{}: {}", header("Encrypted comment"), to_yes_or_no(&meta.encrypted_comment)));
|
||||||
|
|
||||||
information!("{}\n", infos.join("\n"));
|
information!("{}\n", infos.join("\n"));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn from_unix_epoch(t: u64) -> SystemTime {
|
||||||
|
SystemTime::UNIX_EPOCH.add(Duration::from_millis(t))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn header(h: &str) -> String {
|
||||||
|
let width = 18;
|
||||||
|
h.to_string() + ".".repeat(max(width - h.len(), 0)).as_str()
|
||||||
|
}
|
||||||
|
|
||||||
fn to_yes_or_no(opt: &Option<String>) -> String {
|
fn to_yes_or_no(opt: &Option<String>) -> String {
|
||||||
opt.as_ref().map(|_| "YES".to_string()).unwrap_or_else(|| "NO".to_string())
|
opt.as_ref().map(|_| "YES".to_string()).unwrap_or_else(|| "NO".to_string())
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
use std::fs::File;
|
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
use rust_util::{opt_result, simple_error, XResult};
|
use rust_util::{opt_result, simple_error, XResult};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
use std::fs::File;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|||||||
Reference in New Issue
Block a user