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",
]
[[package]]
name = "chrono-humanize"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0a4c32145b4db85fe1c4f2b125a4f9493769df424f5f84baf6b04ea8eaf33c9"
dependencies = [
"chrono",
]
[[package]]
name = "clap"
version = "2.33.3"
@ -80,10 +89,11 @@ dependencies = [
[[package]]
name = "garbage"
version = "0.2.1"
version = "0.2.2"
dependencies = [
"anyhow",
"chrono",
"chrono-humanize",
"lazy_static",
"libc",
"libmount",

View file

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

View file

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