Upgrade dependencies and add git hash to version

This commit is contained in:
Michael Zhang 2021-12-30 22:37:02 -06:00
parent f43568de81
commit 2079ec41b6
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
9 changed files with 114 additions and 94 deletions

124
Cargo.lock generated
View file

@ -2,15 +2,6 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "arrayref" name = "arrayref"
version = "0.3.6" version = "0.3.6"
@ -111,17 +102,32 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.34.0" version = "3.0.0-rc.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" checksum = "e6f243c7279f09ffed852a0a564c72091331651484cdbb32b7287f16df8611a7"
dependencies = [ dependencies = [
"ansi_term",
"atty", "atty",
"bitflags", "bitflags",
"clap_derive",
"indexmap",
"lazy_static",
"os_str_bytes",
"strsim", "strsim",
"termcolor",
"textwrap", "textwrap",
"unicode-width", ]
"vec_map",
[[package]]
name = "clap_derive"
version = "3.0.0-rc.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cd9992739777a4a23535089a8d235eac43044ba8b431d9f54fe334dfa779930"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
] ]
[[package]] [[package]]
@ -183,6 +189,7 @@ version = "0.3.2"
dependencies = [ dependencies = [
"chrono", "chrono",
"chrono-humanize", "chrono-humanize",
"clap",
"lazy_static", "lazy_static",
"libc", "libc",
"libmount", "libmount",
@ -190,7 +197,6 @@ dependencies = [
"percent-encoding", "percent-encoding",
"prettytable-rs", "prettytable-rs",
"stderrlog", "stderrlog",
"structopt",
"thiserror", "thiserror",
"walkdir", "walkdir",
"xdg", "xdg",
@ -218,6 +224,12 @@ dependencies = [
"wasi 0.10.0+wasi-snapshot-preview1", "wasi 0.10.0+wasi-snapshot-preview1",
] ]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.3.3" version = "0.3.3"
@ -236,6 +248,16 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "indexmap"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -268,6 +290,12 @@ dependencies = [
"cfg-if 1.0.0", "cfg-if 1.0.0",
] ]
[[package]]
name = "memchr"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.14.1" version = "0.14.1"
@ -300,6 +328,15 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "os_str_bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.1.0"
@ -345,9 +382,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.34" version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid",
] ]
@ -360,9 +397,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.10" version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -439,39 +476,15 @@ dependencies = [
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.8.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "structopt"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c"
dependencies = [
"clap",
"lazy_static",
"structopt-derive",
]
[[package]]
name = "structopt-derive"
version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.83" version = "1.0.84"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23a1dfb999630e338648c83e91c59a4e9fb7620f520c3194b6b89e276f2f1959" checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -500,12 +513,9 @@ dependencies = [
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.11.0" version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
dependencies = [
"unicode-width",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
@ -565,17 +575,11 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.3" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "void" name = "void"

View file

@ -14,14 +14,14 @@ path = "src/main.rs"
[dependencies] [dependencies]
chrono = "0.4.19" chrono = "0.4.19"
chrono-humanize = "0.2.1" chrono-humanize = "0.2.1"
clap = { version = "3.0.0-rc.11", features = ["derive", "cargo"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
libc = "0.2.97" libc = "0.2.112"
libmount = "0.1.15" libmount = "0.1.15"
log = "0.4.14" log = "0.4.14"
percent-encoding = "2.1.0" percent-encoding = "2.1.0"
prettytable-rs = { version = "0.8.0", default-features = false } prettytable-rs = { version = "0.8.0", default-features = false }
stderrlog = "0.5.1" stderrlog = "0.5.1"
structopt = "0.3.21" thiserror = "1.0.30"
thiserror = "1.0.25"
walkdir = "2.3.2" walkdir = "2.3.2"
xdg = "2.2.0" xdg = "2.4.0"

15
build.rs Normal file
View file

@ -0,0 +1,15 @@
use std::process::Command;
fn get_git_hash() -> Option<String> {
let output = Command::new("git")
.args(&["rev-parse", "--short", "HEAD"])
.output()
.ok()?;
String::from_utf8(output.stdout).ok()
}
fn main() {
if let Some(hash) = get_git_hash() {
println!("cargo:rustc-env=GIT_HASH={}", hash);
}
}

View file

@ -2,13 +2,13 @@
#![warn(missing_docs)] #![warn(missing_docs)]
#[macro_use]
extern crate clap;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;
#[macro_use] #[macro_use]
extern crate structopt;
#[macro_use]
extern crate thiserror; extern crate thiserror;
#[macro_use] #[macro_use]

View file

@ -9,26 +9,27 @@ use garbage::{
ops::{self, EmptyOptions, ListOptions, PutOptions, RestoreOptions}, ops::{self, EmptyOptions, ListOptions, PutOptions, RestoreOptions},
Result, Result,
}; };
use structopt::StructOpt; use clap::{Parser, crate_version};
#[derive(StructOpt)] #[derive(Parser)]
#[clap(about, version = concat!(crate_version!(), "-", env!("GIT_HASH")), author)]
struct Opt { struct Opt {
#[structopt(subcommand)] #[clap(subcommand)]
command: Command, command: Command,
/// Verbosity (-v, -vv, -vvv, etc) /// Verbosity (-v, -vv, -vvv, etc)
#[structopt(short = "v", long = "verbose", parse(from_occurrences))] #[clap(short = 'v', long = "verbose", parse(from_occurrences))]
verbose: usize, verbose: usize,
} }
#[derive(StructOpt)] #[derive(Parser)]
enum Command { enum Command {
/// Empty a trash directory. /// Empty a trash directory.
#[structopt(name = "empty")] #[clap(name = "empty")]
Empty(EmptyOptions), Empty(EmptyOptions),
/// List the contents of a trash directory. /// List the contents of a trash directory.
#[structopt(name = "list")] #[clap(name = "list")]
List(ListOptions), List(ListOptions),
/// Puts files into the trash. (also 'garbage rm') /// Puts files into the trash. (also 'garbage rm')
@ -37,11 +38,11 @@ enum Command {
/// for each file that's deleted (after shell glob expansion). The /// for each file that's deleted (after shell glob expansion). The
/// algorithm for deciding a strategy is specified in the FreeDesktop /// algorithm for deciding a strategy is specified in the FreeDesktop
/// Trash spec. /// Trash spec.
#[structopt(name = "put", alias = "rm")] #[clap(name = "put", alias = "rm")]
Put(PutOptions), Put(PutOptions),
/// Restores files from the trash. /// Restores files from the trash.
#[structopt(name = "restore")] #[clap(name = "restore")]
Restore(RestoreOptions), Restore(RestoreOptions),
} }
@ -55,7 +56,7 @@ fn run(cmd: Command) -> Result<()> {
} }
fn main() { fn main() {
let opt = Opt::from_args(); let opt = Opt::parse();
stderrlog::new() stderrlog::new()
.module(module_path!()) .module(module_path!())

View file

@ -8,26 +8,26 @@ use crate::errors::Result;
use crate::TrashDir; use crate::TrashDir;
/// Options to pass to empty /// Options to pass to empty
#[derive(StructOpt)] #[derive(Parser)]
pub struct EmptyOptions { pub struct EmptyOptions {
/// Only list the files that are to be deleted, without /// Only list the files that are to be deleted, without
/// actually deleting anything. /// actually deleting anything.
#[structopt(long = "dry")] #[clap(long = "dry")]
pub dry: bool, pub dry: bool,
/// Delete all files older than (this number) of integer days. /// Delete all files older than (this number) of integer days.
/// Removes everything if this option is not specified /// Removes everything if this option is not specified
#[structopt(long = "days")] #[clap(long = "days")]
days: Option<u32>, days: Option<u32>,
/// The path to the trash directory to empty. /// The path to the trash directory to empty.
/// By default, this is your home directory's trash ($XDG_DATA_HOME/Trash) /// By default, this is your home directory's trash ($XDG_DATA_HOME/Trash)
#[structopt(long = "trash-dir", parse(from_os_str))] #[clap(long = "trash-dir", parse(from_os_str))]
trash_dir: Option<PathBuf>, trash_dir: Option<PathBuf>,
/// Delete all files in the trash (by default, only files in the current /// Delete all files in the trash (by default, only files in the current
/// directory are listed) /// directory are listed)
#[structopt(short = "a", long = "all")] #[clap(short = 'a', long = "all")]
all: bool, all: bool,
} }

View file

@ -6,16 +6,16 @@ use crate::errors::Result;
use crate::list; use crate::list;
/// Options to pass to list /// Options to pass to list
#[derive(StructOpt)] #[derive(Parser)]
pub struct ListOptions { pub struct ListOptions {
/// The path to the trash directory to list. /// The path to the trash directory to list.
/// By default, this is your home directory's trash ($XDG_DATA_HOME/Trash) /// By default, this is your home directory's trash ($XDG_DATA_HOME/Trash)
#[structopt(long = "trash-dir", parse(from_os_str))] #[clap(long = "trash-dir", parse(from_os_str))]
trash_dir: Option<PathBuf>, trash_dir: Option<PathBuf>,
/// List all files in the trash (by default, only files in the current /// List all files in the trash (by default, only files in the current
/// directory are listed) /// directory are listed)
#[structopt(short = "a", long = "all")] #[clap(short = 'a', long = "all")]
all: bool, all: bool,
} }

View file

@ -29,26 +29,26 @@ pub enum PutError {
} }
/// Options to pass to put /// Options to pass to put
#[derive(StructOpt)] #[derive(Parser)]
pub struct PutOptions { pub struct PutOptions {
/// The target path to be trashed /// The target path to be trashed
#[structopt(parse(from_os_str))] #[clap(parse(from_os_str))]
paths: Vec<PathBuf>, paths: Vec<PathBuf>,
/// Don't actually move anything, just print the files to be removed /// Don't actually move anything, just print the files to be removed
#[structopt(long = "dry")] #[clap(long = "dry")]
dry: bool, dry: bool,
/// Prompt before every removal /// Prompt before every removal
#[structopt(long = "prompt", short = "i")] #[clap(long = "prompt", short = 'i')]
prompt: bool, prompt: bool,
/// Trashes directories recursively (ignored) /// Trashes directories recursively (ignored)
#[structopt(long = "recursive", short = "r")] #[clap(long = "recursive", short = 'r')]
_recursive: bool, _recursive: bool,
/// Suppress prompts/messages /// Suppress prompts/messages
#[structopt(long = "force", short = "f")] #[clap(long = "force", short = 'f')]
force: bool, force: bool,
/// Put all the trashed files into this trash directory /// Put all the trashed files into this trash directory
@ -59,7 +59,7 @@ pub struct PutOptions {
/// ///
/// If this option is not passed, the best strategy will be chosen /// If this option is not passed, the best strategy will be chosen
/// automatically for each file. /// automatically for each file.
#[structopt(long = "trash-dir", parse(from_os_str))] #[clap(long = "trash-dir", parse(from_os_str))]
trash_dir: Option<PathBuf>, trash_dir: Option<PathBuf>,
} }

View file

@ -8,16 +8,16 @@ use crate::list;
use crate::TrashDir; use crate::TrashDir;
/// Options to pass to restore /// Options to pass to restore
#[derive(StructOpt)] #[derive(Parser)]
pub struct RestoreOptions { pub struct RestoreOptions {
/// The path to the trash directory to restore from. /// The path to the trash directory to restore from.
/// By default, this is your home directory's trash ($XDG_DATA_HOME/Trash) /// By default, this is your home directory's trash ($XDG_DATA_HOME/Trash)
#[structopt(long = "trash-dir", parse(from_os_str))] #[clap(long = "trash-dir", parse(from_os_str))]
trash_dir: Option<PathBuf>, trash_dir: Option<PathBuf>,
/// List all files in the trash (by default, only files in the current /// List all files in the trash (by default, only files in the current
/// directory are listed) /// directory are listed)
#[structopt(short = "a", long = "all")] #[clap(short = 'a', long = "all")]
all: bool, all: bool,
} }