From e6f2e85293f4e3c29cde495051dbdd7f8881d94e Mon Sep 17 00:00:00 2001 From: Avril Date: Wed, 7 Oct 2020 01:51:31 +0100 Subject: [PATCH] one point zero! --- Cargo.lock | 78 ++----------------------------------------------- Cargo.toml | 6 ++-- README.org | 50 +++++++++++++++++++++++++++++++ src/main.rs | 1 + src/parallel.rs | 2 +- src/recurse.rs | 2 +- src/serial.rs | 14 ++++++++- 7 files changed, 72 insertions(+), 81 deletions(-) create mode 100644 README.org diff --git a/Cargo.lock b/Cargo.lock index e08429f..d23cd59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,12 +24,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "arc-swap" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" - [[package]] name = "atty" version = "0.2.14" @@ -342,35 +336,12 @@ dependencies = [ "kernel32-sys", "libc", "log", - "miow 0.2.1", + "miow", "net2", "slab", "winapi 0.2.8", ] -[[package]] -name = "mio-named-pipes" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio", - "miow 0.3.5", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio", -] - [[package]] name = "miow" version = "0.2.1" @@ -383,16 +354,6 @@ dependencies = [ "ws2_32-sys", ] -[[package]] -name = "miow" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" -dependencies = [ - "socket2", - "winapi 0.3.9", -] - [[package]] name = "net2" version = "0.2.35" @@ -568,12 +529,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "regex" version = "1.3.9" @@ -624,7 +579,7 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "sever" -version = "0.1.0" +version = "1.0.0" dependencies = [ "cfg-if", "color-eyre", @@ -638,34 +593,12 @@ dependencies = [ "uuid", ] -[[package]] -name = "signal-hook-registry" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035" -dependencies = [ - "arc-swap", - "libc", -] - [[package]] name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -[[package]] -name = "socket2" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi 0.3.9", -] - [[package]] name = "syn" version = "1.0.42" @@ -704,19 +637,12 @@ dependencies = [ "bytes", "fnv", "futures-core", - "iovec", "lazy_static", - "libc", "memchr", "mio", - "mio-named-pipes", - "mio-uds", "num_cpus", "pin-project-lite", - "signal-hook-registry", - "slab", "tokio-macros", - "winapi 0.3.9", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3b848ce..1a920b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,11 @@ [package] name = "sever" description = "Coerce hardlinks into new files" -version = "0.1.0" +version = "1.0.0" authors = ["Avril "] edition = "2018" +readme = "README.org" +license = "GPL-3.0-or-later" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -25,7 +27,7 @@ threads = ["parallel", "tokio/rt-threaded"] [dependencies] cfg-if = "0.1.10" -tokio = {version = "0.2", features = ["full"], optional = true} +tokio = {version = "0.2", features = ["rt-core", "rt-util", "io-driver", "fs", "macros", "sync", "stream"], optional = true} log = "0.4.11" pretty_env_logger = "0.4.0" color-eyre = {version = "0.5.6", default-features=false} diff --git a/README.org b/README.org new file mode 100644 index 0000000..db03fdd --- /dev/null +++ b/README.org @@ -0,0 +1,50 @@ +* sever +Coerce hardlinks into new files + +* Usage +Basic usage is simple: +#+BEGIN_SRC shell + $ sever file1 file2 file3 dir/* +#+END_SRC + +** Logging +To change the verbosity level of output messages, set the ~RUST_LOG~ env var: + + - trace: Most verbose. Show information about files as they're processed and redundant failures + - debug: Verbose. Show all errors and their causes + - info: The default level. Just show completions/failures + - warn: Just show warnings + - error: Just show errors + +* Features +The ~sever~ binary has no flags. Instead, it comes with compile-time feature flags that can be enabled when building: + + | Flag | Description | Default | + |-------------------+-----------------------------------------------------------------+---------| + | parallel | Process files in parallel | On | + | threads | Process files with a multi-threaded scheduler | Off | + | limit-concurrency | Apply a max limit (default 4096) of concurrent operation | On | + | recursive | Allow processing of directories by recursing through them | On | + | limit-recursion | Apply a max depth of recursion (default 256) | On | + | splash | Print program's compiled information when ran with no arguments | On | + +** Building +To build with default features, run: + +#+BEGIN_SRC shell + $ cargo build --release + $ strip target/release/sever +#+END_SRC + +The binary will be built to ~target/release/sever~ + +*** Building with non-default features +To build with your desired features, run: +#+BEGIN_SRC shell + $ cargo build --release --no-default-features --features feature1,feature2,feature3,... + $ strip target/release/sever +#+END_SRC + +The binary will be built to ~target/release/sever~ +* License +GPL'd with <3 diff --git a/src/main.rs b/src/main.rs index e811b70..d25b203 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] +#![allow(unused_imports)] #[macro_use] extern crate log; #[macro_use] mod macros; diff --git a/src/parallel.rs b/src/parallel.rs index 1089498..918438c 100644 --- a/src/parallel.rs +++ b/src/parallel.rs @@ -141,7 +141,7 @@ pub async fn main>(list: I) -> eyre::Result<()> }, Ok(Err(k)) => { failures.push((k.path().to_owned(), k.to_string())); - trace!("<{:?}> Failed (skipped)", k.path()); + warn!("<{:?}> Failed (skipped)", k.path()); }, } done+=1; diff --git a/src/recurse.rs b/src/recurse.rs index deb0601..bdc3000 100644 --- a/src/recurse.rs +++ b/src/recurse.rs @@ -41,7 +41,7 @@ impl fmt::Display for Recursion match self { Self::N(n) => write!(f, "{}", n), Self::All => write!(f, "unlimited"), - _ => write!(f, "no"), + #[allow(unreachable_patterns)] _ => write!(f, "no"), } } } diff --git a/src/serial.rs b/src/serial.rs index d1ff719..0dfa80d 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -64,9 +64,21 @@ pub fn main>(list: I) -> eyre::Result<()> match work(file) { Ok((path, true)) => info!("<{:?}> OK (processed)", path), Ok((path, false)) => info!("<{:?}> OK (skipped)", path), + Err(kind) if !kind.kind().is_skippable() => { + failures.push((kind.path().to_owned(), kind.to_string())); + let fuck = format!("{:?}", kind.path()); + let sug = kind.kind().suggestion(); + let err = Err::(kind) + .wrap_err_with(|| eyre!("<{}> Failed", fuck)) + .with_section(move || fuck.header("Path was")) + .with_suggestion(|| sug) + .unwrap_err(); + error!("{}", err); + debug!("Error: {:?}", err); + }, Err(k) => { failures.push((k.path().to_owned(), k.to_string())); - trace!("<{:?}> Failed (skipped)", k.path()); + warn!("<{:?}> Failed (skipped)", k.path()); }, } done+=1;