Add humanized timestamp

This commit is contained in:
Michael Zhang 2020-10-31 20:02:48 -05:00
parent 39690f873f
commit 69f815e653
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
3 changed files with 28 additions and 18 deletions

12
Cargo.lock generated
View file

@ -63,6 +63,15 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "chrono-humanize"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0a4c32145b4db85fe1c4f2b125a4f9493769df424f5f84baf6b04ea8eaf33c9"
dependencies = [
"chrono",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.33.3" version = "2.33.3"
@ -80,10 +89,11 @@ dependencies = [
[[package]] [[package]]
name = "garbage" name = "garbage"
version = "0.2.1" version = "0.2.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
"chrono-humanize",
"lazy_static", "lazy_static",
"libc", "libc",
"libmount", "libmount",

View file

@ -1,28 +1,25 @@
[package] [package]
name = "garbage" name = "garbage"
version = "0.2.1" version = "0.2.2"
authors = ["Michael Zhang <iptq@protonmail.com>"] authors = ["Michael Zhang <iptq@protonmail.com>"]
description = "cli tool for interacting with the freedesktop trashcan" description = "cli tool for interacting with the freedesktop trashcan"
license = "MIT" license = "MIT"
edition = "2018" edition = "2018"
[profile.release]
lto = true
panic = "abort"
[[bin]] [[bin]]
name = "garbage" name = "garbage"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
anyhow = "1.0.33" anyhow = "1.0"
chrono = "0.4.19" chrono = "0.4"
lazy_static = "1.4.0" chrono-humanize = "0.1.1"
libc = "0.2.80" lazy_static = "1.4"
libmount = "0.1.15" libc = "0.2"
log = "0.4.11" libmount = "0.1"
structopt = "0.3.20" log = "0.4"
thiserror = "1.0.21" percent-encoding = "2.1"
walkdir = "2.3.1" structopt = "0.3"
xdg = "2.2.0" thiserror = "1.0"
percent-encoding = "2.1.0" walkdir = "2.3"
xdg = "2.2"

View file

@ -1,6 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use anyhow::Result; use anyhow::Result;
use chrono_humanize::HumanTime;
use crate::utils; use crate::utils;
use crate::TrashDir; use crate::TrashDir;
@ -30,10 +31,12 @@ pub fn list(options: ListOptions) -> Result<()> {
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
files.sort_unstable_by_key(|info| info.deletion_date); files.sort_unstable_by_key(|info| info.deletion_date);
for info in files { for info in files {
println!( println!(
"{}\t{}", "{}\t{}\t{}",
info.deletion_date, info.deletion_date,
HumanTime::from(info.deletion_date),
utils::percent_encode(info.path) utils::percent_encode(info.path)
); );
} }