Upgrade dependencies and add git hash to version
This commit is contained in:
parent
f43568de81
commit
2079ec41b6
9 changed files with 114 additions and 94 deletions
124
Cargo.lock
generated
124
Cargo.lock
generated
|
@ -2,15 +2,6 @@
|
|||
# It is not intended for manual editing.
|
||||
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]]
|
||||
name = "arrayref"
|
||||
version = "0.3.6"
|
||||
|
@ -111,17 +102,32 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.34.0"
|
||||
version = "3.0.0-rc.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
checksum = "e6f243c7279f09ffed852a0a564c72091331651484cdbb32b7287f16df8611a7"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"os_str_bytes",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"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]]
|
||||
|
@ -183,6 +189,7 @@ version = "0.3.2"
|
|||
dependencies = [
|
||||
"chrono",
|
||||
"chrono-humanize",
|
||||
"clap",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"libmount",
|
||||
|
@ -190,7 +197,6 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
"prettytable-rs",
|
||||
"stderrlog",
|
||||
"structopt",
|
||||
"thiserror",
|
||||
"walkdir",
|
||||
"xdg",
|
||||
|
@ -218,6 +224,12 @@ dependencies = [
|
|||
"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]]
|
||||
name = "heck"
|
||||
version = "0.3.3"
|
||||
|
@ -236,6 +248,16 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
@ -268,6 +290,12 @@ dependencies = [
|
|||
"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]]
|
||||
name = "nix"
|
||||
version = "0.14.1"
|
||||
|
@ -300,6 +328,15 @@ dependencies = [
|
|||
"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]]
|
||||
name = "percent-encoding"
|
||||
version = "2.1.0"
|
||||
|
@ -345,9 +382,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.34"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1"
|
||||
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
@ -360,9 +397,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.10"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
|
||||
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -439,39 +476,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[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",
|
||||
]
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.83"
|
||||
version = "1.0.84"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23a1dfb999630e338648c83e91c59a4e9fb7620f520c3194b6b89e276f2f1959"
|
||||
checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -500,12 +513,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
|
@ -565,17 +575,11 @@ version = "0.2.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.3"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
|
|
|
@ -14,14 +14,14 @@ path = "src/main.rs"
|
|||
[dependencies]
|
||||
chrono = "0.4.19"
|
||||
chrono-humanize = "0.2.1"
|
||||
clap = { version = "3.0.0-rc.11", features = ["derive", "cargo"] }
|
||||
lazy_static = "1.4.0"
|
||||
libc = "0.2.97"
|
||||
libc = "0.2.112"
|
||||
libmount = "0.1.15"
|
||||
log = "0.4.14"
|
||||
percent-encoding = "2.1.0"
|
||||
prettytable-rs = { version = "0.8.0", default-features = false }
|
||||
stderrlog = "0.5.1"
|
||||
structopt = "0.3.21"
|
||||
thiserror = "1.0.25"
|
||||
thiserror = "1.0.30"
|
||||
walkdir = "2.3.2"
|
||||
xdg = "2.2.0"
|
||||
xdg = "2.4.0"
|
||||
|
|
15
build.rs
Normal file
15
build.rs
Normal 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);
|
||||
}
|
||||
}
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
#[macro_use]
|
||||
extern crate structopt;
|
||||
#[macro_use]
|
||||
extern crate thiserror;
|
||||
|
||||
#[macro_use]
|
||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -9,26 +9,27 @@ use garbage::{
|
|||
ops::{self, EmptyOptions, ListOptions, PutOptions, RestoreOptions},
|
||||
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 {
|
||||
#[structopt(subcommand)]
|
||||
#[clap(subcommand)]
|
||||
command: Command,
|
||||
|
||||
/// Verbosity (-v, -vv, -vvv, etc)
|
||||
#[structopt(short = "v", long = "verbose", parse(from_occurrences))]
|
||||
#[clap(short = 'v', long = "verbose", parse(from_occurrences))]
|
||||
verbose: usize,
|
||||
}
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
enum Command {
|
||||
/// Empty a trash directory.
|
||||
#[structopt(name = "empty")]
|
||||
#[clap(name = "empty")]
|
||||
Empty(EmptyOptions),
|
||||
|
||||
/// List the contents of a trash directory.
|
||||
#[structopt(name = "list")]
|
||||
#[clap(name = "list")]
|
||||
List(ListOptions),
|
||||
|
||||
/// 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
|
||||
/// algorithm for deciding a strategy is specified in the FreeDesktop
|
||||
/// Trash spec.
|
||||
#[structopt(name = "put", alias = "rm")]
|
||||
#[clap(name = "put", alias = "rm")]
|
||||
Put(PutOptions),
|
||||
|
||||
/// Restores files from the trash.
|
||||
#[structopt(name = "restore")]
|
||||
#[clap(name = "restore")]
|
||||
Restore(RestoreOptions),
|
||||
}
|
||||
|
||||
|
@ -55,7 +56,7 @@ fn run(cmd: Command) -> Result<()> {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let opt = Opt::from_args();
|
||||
let opt = Opt::parse();
|
||||
|
||||
stderrlog::new()
|
||||
.module(module_path!())
|
||||
|
|
|
@ -8,26 +8,26 @@ use crate::errors::Result;
|
|||
use crate::TrashDir;
|
||||
|
||||
/// Options to pass to empty
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct EmptyOptions {
|
||||
/// Only list the files that are to be deleted, without
|
||||
/// actually deleting anything.
|
||||
#[structopt(long = "dry")]
|
||||
#[clap(long = "dry")]
|
||||
pub dry: bool,
|
||||
|
||||
/// Delete all files older than (this number) of integer days.
|
||||
/// Removes everything if this option is not specified
|
||||
#[structopt(long = "days")]
|
||||
#[clap(long = "days")]
|
||||
days: Option<u32>,
|
||||
|
||||
/// The path to the trash directory to empty.
|
||||
/// 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>,
|
||||
|
||||
/// Delete all files in the trash (by default, only files in the current
|
||||
/// directory are listed)
|
||||
#[structopt(short = "a", long = "all")]
|
||||
#[clap(short = 'a', long = "all")]
|
||||
all: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -6,16 +6,16 @@ use crate::errors::Result;
|
|||
use crate::list;
|
||||
|
||||
/// Options to pass to list
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct ListOptions {
|
||||
/// The path to the trash directory to list.
|
||||
/// 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>,
|
||||
|
||||
/// List all files in the trash (by default, only files in the current
|
||||
/// directory are listed)
|
||||
#[structopt(short = "a", long = "all")]
|
||||
#[clap(short = 'a', long = "all")]
|
||||
all: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -29,26 +29,26 @@ pub enum PutError {
|
|||
}
|
||||
|
||||
/// Options to pass to put
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct PutOptions {
|
||||
/// The target path to be trashed
|
||||
#[structopt(parse(from_os_str))]
|
||||
#[clap(parse(from_os_str))]
|
||||
paths: Vec<PathBuf>,
|
||||
|
||||
/// Don't actually move anything, just print the files to be removed
|
||||
#[structopt(long = "dry")]
|
||||
#[clap(long = "dry")]
|
||||
dry: bool,
|
||||
|
||||
/// Prompt before every removal
|
||||
#[structopt(long = "prompt", short = "i")]
|
||||
#[clap(long = "prompt", short = 'i')]
|
||||
prompt: bool,
|
||||
|
||||
/// Trashes directories recursively (ignored)
|
||||
#[structopt(long = "recursive", short = "r")]
|
||||
#[clap(long = "recursive", short = 'r')]
|
||||
_recursive: bool,
|
||||
|
||||
/// Suppress prompts/messages
|
||||
#[structopt(long = "force", short = "f")]
|
||||
#[clap(long = "force", short = 'f')]
|
||||
force: bool,
|
||||
|
||||
/// 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
|
||||
/// automatically for each file.
|
||||
#[structopt(long = "trash-dir", parse(from_os_str))]
|
||||
#[clap(long = "trash-dir", parse(from_os_str))]
|
||||
trash_dir: Option<PathBuf>,
|
||||
}
|
||||
|
||||
|
|
|
@ -8,16 +8,16 @@ use crate::list;
|
|||
use crate::TrashDir;
|
||||
|
||||
/// Options to pass to restore
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct RestoreOptions {
|
||||
/// The path to the trash directory to restore from.
|
||||
/// 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>,
|
||||
|
||||
/// List all files in the trash (by default, only files in the current
|
||||
/// directory are listed)
|
||||
#[structopt(short = "a", long = "all")]
|
||||
#[clap(short = 'a', long = "all")]
|
||||
all: bool,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue