diff --git a/Cargo.lock b/Cargo.lock index 315c09f50..57aa90ae0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2029,7 +2029,6 @@ dependencies = [ "clap 3.0.10", "platform-info", "uucore", - "uucore_procs", ] [[package]] @@ -2038,7 +2037,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2047,7 +2045,6 @@ version = "0.0.12" dependencies = [ "uu_base32", "uucore", - "uucore_procs", ] [[package]] @@ -2056,7 +2053,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2066,7 +2062,6 @@ dependencies = [ "clap 3.0.10", "uu_base32", "uucore", - "uucore_procs", ] [[package]] @@ -2079,7 +2074,6 @@ dependencies = [ "thiserror", "unix_socket", "uucore", - "uucore_procs", "winapi-util", ] @@ -2093,7 +2087,6 @@ dependencies = [ "selinux", "thiserror", "uucore", - "uucore_procs", ] [[package]] @@ -2102,7 +2095,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2112,7 +2104,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", "walkdir", ] @@ -2122,7 +2113,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2131,7 +2121,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2141,7 +2130,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2151,7 +2139,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2166,7 +2153,6 @@ dependencies = [ "quick-error 1.2.3", "selinux", "uucore", - "uucore_procs", "walkdir", "winapi 0.3.9", "xattr", @@ -2180,7 +2166,6 @@ dependencies = [ "regex", "thiserror", "uucore", - "uucore_procs", ] [[package]] @@ -2192,7 +2177,6 @@ dependencies = [ "clap 3.0.10", "memchr 2.4.1", "uucore", - "uucore_procs", ] [[package]] @@ -2203,7 +2187,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", "winapi 0.3.9", ] @@ -2218,7 +2201,6 @@ dependencies = [ "signal-hook", "tempfile", "uucore", - "uucore_procs", ] [[package]] @@ -2228,7 +2210,6 @@ dependencies = [ "clap 3.0.10", "number_prefix", "uucore", - "uucore_procs", ] [[package]] @@ -2238,7 +2219,6 @@ dependencies = [ "clap 3.0.10", "glob", "uucore", - "uucore_procs", ] [[package]] @@ -2248,7 +2228,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2258,7 +2237,6 @@ dependencies = [ "chrono", "clap 3.0.10", "uucore", - "uucore_procs", "winapi 0.3.9", ] @@ -2268,7 +2246,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2279,7 +2256,6 @@ dependencies = [ "libc", "rust-ini", "uucore", - "uucore_procs", ] [[package]] @@ -2289,7 +2265,6 @@ dependencies = [ "clap 3.0.10", "unicode-width", "uucore", - "uucore_procs", ] [[package]] @@ -2302,7 +2277,6 @@ dependencies = [ "num-traits", "onig", "uucore", - "uucore_procs", ] [[package]] @@ -2317,7 +2291,6 @@ dependencies = [ "rand", "smallvec", "uucore", - "uucore_procs", ] [[package]] @@ -2326,7 +2299,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2337,7 +2309,6 @@ dependencies = [ "libc", "unicode-width", "uucore", - "uucore_procs", ] [[package]] @@ -2346,7 +2317,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2355,7 +2325,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2375,7 +2344,6 @@ dependencies = [ "sha2", "sha3", "uucore", - "uucore_procs", ] [[package]] @@ -2385,7 +2353,6 @@ dependencies = [ "clap 3.0.10", "memchr 2.4.1", "uucore", - "uucore_procs", ] [[package]] @@ -2395,7 +2362,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2406,7 +2372,6 @@ dependencies = [ "hostname", "libc", "uucore", - "uucore_procs", "winapi 0.3.9", ] @@ -2417,7 +2382,6 @@ dependencies = [ "clap 3.0.10", "selinux", "uucore", - "uucore_procs", ] [[package]] @@ -2430,7 +2394,6 @@ dependencies = [ "libc", "time", "uucore", - "uucore_procs", ] [[package]] @@ -2439,7 +2402,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2449,7 +2411,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2459,7 +2420,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2469,7 +2429,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2479,7 +2438,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2499,7 +2457,6 @@ dependencies = [ "termsize", "unicode-width", "uucore", - "uucore_procs", ] [[package]] @@ -2509,7 +2466,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2519,7 +2475,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2529,7 +2484,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2540,7 +2494,6 @@ dependencies = [ "rand", "tempfile", "uucore", - "uucore_procs", ] [[package]] @@ -2556,7 +2509,6 @@ dependencies = [ "unicode-segmentation", "unicode-width", "uucore", - "uucore_procs", ] [[package]] @@ -2566,7 +2518,6 @@ dependencies = [ "clap 3.0.10", "fs_extra", "uucore", - "uucore_procs", ] [[package]] @@ -2577,7 +2528,6 @@ dependencies = [ "libc", "nix 0.23.1", "uucore", - "uucore_procs", ] [[package]] @@ -2591,7 +2541,6 @@ dependencies = [ "regex", "regex-syntax", "uucore", - "uucore_procs", ] [[package]] @@ -2602,7 +2551,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2613,7 +2561,6 @@ dependencies = [ "libc", "num_cpus", "uucore", - "uucore_procs", ] [[package]] @@ -2622,7 +2569,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2634,7 +2580,6 @@ dependencies = [ "half", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2643,7 +2588,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2653,7 +2597,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2662,7 +2605,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2676,7 +2618,6 @@ dependencies = [ "quick-error 2.0.1", "regex", "uucore", - "uucore_procs", ] [[package]] @@ -2685,7 +2626,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2695,7 +2635,6 @@ dependencies = [ "clap 3.0.10", "itertools", "uucore", - "uucore_procs", ] [[package]] @@ -2709,7 +2648,6 @@ dependencies = [ "regex", "regex-syntax", "uucore", - "uucore_procs", ] [[package]] @@ -2718,7 +2656,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2728,7 +2665,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2737,7 +2673,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2746,7 +2681,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2756,7 +2690,6 @@ dependencies = [ "clap 3.0.10", "remove_dir_all", "uucore", - "uucore_procs", "walkdir", "winapi 0.3.9", ] @@ -2768,7 +2701,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2781,7 +2713,6 @@ dependencies = [ "selinux", "thiserror", "uucore", - "uucore_procs", ] [[package]] @@ -2793,7 +2724,6 @@ dependencies = [ "num-bigint", "num-traits", "uucore", - "uucore_procs", ] [[package]] @@ -2804,7 +2734,6 @@ dependencies = [ "libc", "rand", "uucore", - "uucore_procs", ] [[package]] @@ -2815,7 +2744,6 @@ dependencies = [ "rand", "rand_core", "uucore", - "uucore_procs", ] [[package]] @@ -2824,7 +2752,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2844,7 +2771,6 @@ dependencies = [ "tempfile", "unicode-width", "uucore", - "uucore_procs", ] [[package]] @@ -2853,7 +2779,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2862,7 +2787,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2873,7 +2797,6 @@ dependencies = [ "tempfile", "uu_stdbuf_libstdbuf", "uucore", - "uucore_procs", ] [[package]] @@ -2884,7 +2807,6 @@ dependencies = [ "cpp_build", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -2893,7 +2815,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -2903,7 +2824,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", "winapi 0.3.9", ] @@ -2916,7 +2836,6 @@ dependencies = [ "memmap2", "regex", "uucore", - "uucore_procs", ] [[package]] @@ -2928,7 +2847,6 @@ dependencies = [ "nix 0.23.1", "redox_syscall", "uucore", - "uucore_procs", "winapi 0.3.9", ] @@ -2940,7 +2858,6 @@ dependencies = [ "libc", "retain_mut", "uucore", - "uucore_procs", ] [[package]] @@ -2951,7 +2868,6 @@ dependencies = [ "libc", "redox_syscall", "uucore", - "uucore_procs", ] [[package]] @@ -2962,7 +2878,6 @@ dependencies = [ "libc", "nix 0.23.1", "uucore", - "uucore_procs", ] [[package]] @@ -2973,7 +2888,6 @@ dependencies = [ "filetime", "time", "uucore", - "uucore_procs", ] [[package]] @@ -2983,7 +2897,6 @@ dependencies = [ "clap 3.0.10", "nom", "uucore", - "uucore_procs", ] [[package]] @@ -2992,7 +2905,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -3001,7 +2913,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -3010,7 +2921,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -3021,7 +2931,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", ] [[package]] @@ -3031,7 +2940,6 @@ dependencies = [ "clap 3.0.10", "platform-info", "uucore", - "uucore_procs", ] [[package]] @@ -3041,7 +2949,6 @@ dependencies = [ "clap 3.0.10", "unicode-width", "uucore", - "uucore_procs", ] [[package]] @@ -3052,7 +2959,6 @@ dependencies = [ "strum", "strum_macros", "uucore", - "uucore_procs", ] [[package]] @@ -3061,7 +2967,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -3071,7 +2976,6 @@ dependencies = [ "chrono", "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -3080,7 +2984,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -3094,7 +2997,6 @@ dependencies = [ "unicode-width", "utf-8", "uucore", - "uucore_procs", ] [[package]] @@ -3103,7 +3005,6 @@ version = "0.0.12" dependencies = [ "clap 3.0.10", "uucore", - "uucore_procs", ] [[package]] @@ -3113,7 +3014,6 @@ dependencies = [ "clap 3.0.10", "libc", "uucore", - "uucore_procs", "winapi 0.3.9", ] @@ -3124,7 +3024,6 @@ dependencies = [ "clap 3.0.10", "nix 0.23.1", "uucore", - "uucore_procs", ] [[package]] @@ -3145,6 +3044,7 @@ dependencies = [ "termion", "thiserror", "time", + "uucore_procs", "walkdir", "wild", "winapi 0.3.9", @@ -3158,7 +3058,6 @@ version = "0.0.12" dependencies = [ "proc-macro2", "quote 1.0.14", - "syn", ] [[package]] diff --git a/README.md b/README.md index 26d2e0ca1..5a663b474 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ writing cross-platform code. uutils has both user and developer documentation available: - [User Manual](https://uutils.github.io/coreutils-docs/user/) -- [Developer Documentation](https://uutils.github.io/coreutils-docs/dev/) +- [Developer Documentation](https://uutils.github.io/coreutils-docs/dev/coreutils/) Both can also be generated locally, the instructions for that can be found in the [coreutils docs](https://github.com/uutils/coreutils-docs) repository. diff --git a/src/uu/arch/Cargo.toml b/src/uu/arch/Cargo.toml index 9a95cb7fa..85888c498 100644 --- a/src/uu/arch/Cargo.toml +++ b/src/uu/arch/Cargo.toml @@ -18,11 +18,7 @@ path = "src/arch.rs" platform-info = "0.2" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "arch" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/arch/src/arch.rs b/src/uu/arch/src/arch.rs index cde63955e..b588adbb9 100644 --- a/src/uu/arch/src/arch.rs +++ b/src/uu/arch/src/arch.rs @@ -14,7 +14,7 @@ use uucore::error::{FromIo, UResult}; static ABOUT: &str = "Display machine architecture"; static SUMMARY: &str = "Determine architecture name for current machine."; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { uu_app().get_matches_from(args); diff --git a/src/uu/arch/src/main.rs b/src/uu/arch/src/main.rs index e2668864c..a47da8346 100644 --- a/src/uu/arch/src/main.rs +++ b/src/uu/arch/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_arch); +uucore::bin!(uu_arch); diff --git a/src/uu/base32/Cargo.toml b/src/uu/base32/Cargo.toml index 3cab8c157..cb8ccc3aa 100644 --- a/src/uu/base32/Cargo.toml +++ b/src/uu/base32/Cargo.toml @@ -17,11 +17,7 @@ path = "src/base32.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "base32" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/base32/src/base32.rs b/src/uu/base32/src/base32.rs index 329a4ec84..6d9759fa4 100644 --- a/src/uu/base32/src/base32.rs +++ b/src/uu/base32/src/base32.rs @@ -26,7 +26,7 @@ fn usage() -> String { format!("{0} [OPTION]... [FILE]", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let format = Format::Base32; let usage = usage(); diff --git a/src/uu/base32/src/main.rs b/src/uu/base32/src/main.rs index 83a0b6607..e7ab9a5fd 100644 --- a/src/uu/base32/src/main.rs +++ b/src/uu/base32/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_base32); +uucore::bin!(uu_base32); diff --git a/src/uu/base64/Cargo.toml b/src/uu/base64/Cargo.toml index 9ffedd884..d30df608b 100644 --- a/src/uu/base64/Cargo.toml +++ b/src/uu/base64/Cargo.toml @@ -16,12 +16,8 @@ path = "src/base64.rs" [dependencies] uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"} [[bin]] name = "base64" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/base64/src/base64.rs b/src/uu/base64/src/base64.rs index c041d6d69..6d0192df9 100644 --- a/src/uu/base64/src/base64.rs +++ b/src/uu/base64/src/base64.rs @@ -27,7 +27,7 @@ fn usage() -> String { format!("{0} [OPTION]... [FILE]", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let format = Format::Base64; let usage = usage(); diff --git a/src/uu/base64/src/main.rs b/src/uu/base64/src/main.rs index cae6cb3c4..ea5728880 100644 --- a/src/uu/base64/src/main.rs +++ b/src/uu/base64/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_base64); +uucore::bin!(uu_base64); diff --git a/src/uu/basename/Cargo.toml b/src/uu/basename/Cargo.toml index b10188b8f..da93877c0 100644 --- a/src/uu/basename/Cargo.toml +++ b/src/uu/basename/Cargo.toml @@ -17,11 +17,7 @@ path = "src/basename.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "basename" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/basename/src/basename.rs b/src/uu/basename/src/basename.rs index d2b797d05..b3afe7d7d 100644 --- a/src/uu/basename/src/basename.rs +++ b/src/uu/basename/src/basename.rs @@ -31,7 +31,7 @@ pub mod options { pub static ZERO: &str = "zero"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/basename/src/main.rs b/src/uu/basename/src/main.rs index aa452f750..68d003269 100644 --- a/src/uu/basename/src/main.rs +++ b/src/uu/basename/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_basename); +uucore::bin!(uu_basename); diff --git a/src/uu/basenc/Cargo.toml b/src/uu/basenc/Cargo.toml index b83a512f6..07a7b7f67 100644 --- a/src/uu/basenc/Cargo.toml +++ b/src/uu/basenc/Cargo.toml @@ -17,12 +17,8 @@ path = "src/basenc.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features = ["encoding"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } uu_base32 = { version=">=0.0.8", package="uu_base32", path="../base32"} [[bin]] name = "basenc" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/basenc/src/basenc.rs b/src/uu/basenc/src/basenc.rs index 68d572ca6..c21e224da 100644 --- a/src/uu/basenc/src/basenc.rs +++ b/src/uu/basenc/src/basenc.rs @@ -65,7 +65,7 @@ fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> { Ok((config, format)) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let (config, format) = parse_cmd_args(args)?; // Create a reference to stdin so we can return a locked stdin from diff --git a/src/uu/basenc/src/main.rs b/src/uu/basenc/src/main.rs index 9a9a5f4c6..a035e9a68 100644 --- a/src/uu/basenc/src/main.rs +++ b/src/uu/basenc/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_basenc); +uucore::bin!(uu_basenc); diff --git a/src/uu/cat/Cargo.toml b/src/uu/cat/Cargo.toml index e22fc7f32..e1e95bc76 100644 --- a/src/uu/cat/Cargo.toml +++ b/src/uu/cat/Cargo.toml @@ -19,7 +19,6 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } thiserror = "1.0" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "pipes"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(unix)'.dependencies] unix_socket = "0.5.0" @@ -31,6 +30,3 @@ winapi-util = "0.1.5" [[bin]] name = "cat" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/cat/src/cat.rs b/src/uu/cat/src/cat.rs index 47f216730..3f17124f8 100644 --- a/src/uu/cat/src/cat.rs +++ b/src/uu/cat/src/cat.rs @@ -182,7 +182,7 @@ mod options { pub static SHOW_NONPRINTING: &str = "show-nonprinting"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/cat/src/main.rs b/src/uu/cat/src/main.rs index 1adab666b..df198c960 100644 --- a/src/uu/cat/src/main.rs +++ b/src/uu/cat/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cat); +uucore::bin!(uu_cat); diff --git a/src/uu/chcon/Cargo.toml b/src/uu/chcon/Cargo.toml index 01f075476..a0a526d3b 100644 --- a/src/uu/chcon/Cargo.toml +++ b/src/uu/chcon/Cargo.toml @@ -16,7 +16,6 @@ path = "src/chcon.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } -uucore_procs = { version = ">=0.0.6", package="uucore_procs", path="../../uucore_procs" } selinux = { version = "0.2" } fts-sys = { version = "0.2" } thiserror = { version = "1.0" } @@ -25,6 +24,3 @@ libc = { version = "0.2" } [[bin]] name = "chcon" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index eebd9d446..0b373c5e0 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -61,7 +61,7 @@ fn get_usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = get_usage(); diff --git a/src/uu/chcon/src/main.rs b/src/uu/chcon/src/main.rs index e23b34c5b..d93d7d1da 100644 --- a/src/uu/chcon/src/main.rs +++ b/src/uu/chcon/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chcon); +uucore::bin!(uu_chcon); diff --git a/src/uu/chgrp/Cargo.toml b/src/uu/chgrp/Cargo.toml index b2bd6ef0f..3800daa6c 100644 --- a/src/uu/chgrp/Cargo.toml +++ b/src/uu/chgrp/Cargo.toml @@ -17,11 +17,7 @@ path = "src/chgrp.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "chgrp" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/chgrp/src/chgrp.rs b/src/uu/chgrp/src/chgrp.rs index cccc0b582..d228155b6 100644 --- a/src/uu/chgrp/src/chgrp.rs +++ b/src/uu/chgrp/src/chgrp.rs @@ -51,7 +51,7 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<(Option, Option, Ok((dest_gid, None, IfFrom::All)) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = get_usage(); diff --git a/src/uu/chgrp/src/main.rs b/src/uu/chgrp/src/main.rs index ee6f70a8b..7d5330a61 100644 --- a/src/uu/chgrp/src/main.rs +++ b/src/uu/chgrp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chgrp); +uucore::bin!(uu_chgrp); diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index c51d3e25f..237368cf4 100644 --- a/src/uu/chmod/Cargo.toml +++ b/src/uu/chmod/Cargo.toml @@ -18,12 +18,8 @@ path = "src/chmod.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } walkdir = "2.2" [[bin]] name = "chmod" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/chmod/src/chmod.rs b/src/uu/chmod/src/chmod.rs index de9fc90f8..9cf108eeb 100644 --- a/src/uu/chmod/src/chmod.rs +++ b/src/uu/chmod/src/chmod.rs @@ -48,7 +48,7 @@ fn get_long_usage() -> String { String::from("Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+'.") } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let mut args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/chmod/src/main.rs b/src/uu/chmod/src/main.rs index adaf887f8..f0ec0c2e9 100644 --- a/src/uu/chmod/src/main.rs +++ b/src/uu/chmod/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chmod); +uucore::bin!(uu_chmod); diff --git a/src/uu/chown/Cargo.toml b/src/uu/chown/Cargo.toml index 1b3cddb0a..ed84d3fbb 100644 --- a/src/uu/chown/Cargo.toml +++ b/src/uu/chown/Cargo.toml @@ -17,11 +17,7 @@ path = "src/chown.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "chown" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs index 683274ae7..06137e200 100644 --- a/src/uu/chown/src/chown.rs +++ b/src/uu/chown/src/chown.rs @@ -54,7 +54,7 @@ fn parse_gid_uid_and_filter(matches: &ArgMatches) -> UResult<(Option, Optio Ok((dest_gid, dest_uid, filter)) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = get_usage(); diff --git a/src/uu/chown/src/main.rs b/src/uu/chown/src/main.rs index b3ed39970..db3a4f1d2 100644 --- a/src/uu/chown/src/main.rs +++ b/src/uu/chown/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chown); +uucore::bin!(uu_chown); diff --git a/src/uu/chroot/Cargo.toml b/src/uu/chroot/Cargo.toml index 31fdc431c..ef745009c 100644 --- a/src/uu/chroot/Cargo.toml +++ b/src/uu/chroot/Cargo.toml @@ -17,11 +17,7 @@ path = "src/chroot.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "chroot" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index aba2f972a..179880b14 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -31,7 +31,7 @@ mod options { pub const COMMAND: &str = "command"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/chroot/src/main.rs b/src/uu/chroot/src/main.rs index 0ca88cfaf..a8ccd8254 100644 --- a/src/uu/chroot/src/main.rs +++ b/src/uu/chroot/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_chroot); +uucore::bin!(uu_chroot); diff --git a/src/uu/cksum/Cargo.toml b/src/uu/cksum/Cargo.toml index c22615d01..5a6076648 100644 --- a/src/uu/cksum/Cargo.toml +++ b/src/uu/cksum/Cargo.toml @@ -18,11 +18,7 @@ path = "src/cksum.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "cksum" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/cksum/src/cksum.rs b/src/uu/cksum/src/cksum.rs index 3da10f110..ee47bfaa9 100644 --- a/src/uu/cksum/src/cksum.rs +++ b/src/uu/cksum/src/cksum.rs @@ -112,7 +112,7 @@ mod options { pub static FILE: &str = "file"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/cksum/src/main.rs b/src/uu/cksum/src/main.rs index b8a8f6b33..8cab56681 100644 --- a/src/uu/cksum/src/main.rs +++ b/src/uu/cksum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cksum); +uucore::bin!(uu_cksum); diff --git a/src/uu/comm/Cargo.toml b/src/uu/comm/Cargo.toml index 2a4f1ef04..8d9babdcb 100644 --- a/src/uu/comm/Cargo.toml +++ b/src/uu/comm/Cargo.toml @@ -18,11 +18,7 @@ path = "src/comm.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "comm" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 53ac2e705..dd1281935 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -130,7 +130,7 @@ fn open_file(name: &str) -> io::Result { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let args = args diff --git a/src/uu/comm/src/main.rs b/src/uu/comm/src/main.rs index 07ac07544..0417389c2 100644 --- a/src/uu/comm/src/main.rs +++ b/src/uu/comm/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_comm); +uucore::bin!(uu_comm); diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 3e0632c89..d0ba419d0 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -25,7 +25,6 @@ libc = "0.2.85" quick-error = "1.2.3" selinux = { version="0.2", optional=true } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } walkdir = "2.2" [target.'cfg(target_os = "linux")'.dependencies] @@ -45,6 +44,3 @@ path = "src/main.rs" [features] feat_selinux = ["selinux"] feat_acl = ["exacl"] - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index 43c28d447..d005bd718 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -454,7 +454,7 @@ pub fn uu_app<'a>() -> App<'a> { .multiple_occurrences(true)) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app() @@ -768,8 +768,8 @@ fn preserve_hardlinks( let mut stat = mem::zeroed(); if libc::lstat(src_path.as_ptr(), &mut stat) < 0 { return Err(format!( - "cannot stat {:?}: {}", - src_path, + "cannot stat {}: {}", + source.quote(), std::io::Error::last_os_error() ) .into()); @@ -849,7 +849,7 @@ fn copy(sources: &[Source], target: &TargetSlice, options: &Options) -> CopyResu let mut found_hard_link = false; if preserve_hard_links { let dest = construct_dest_path(source, target, &target_type, options)?; - preserve_hardlinks(&mut hard_links, source, dest, &mut found_hard_link).unwrap(); + preserve_hardlinks(&mut hard_links, source, dest, &mut found_hard_link)?; } if !found_hard_link { if let Err(error) = @@ -1031,7 +1031,7 @@ fn copy_directory( let mut found_hard_link = false; let source = path.to_path_buf(); let dest = local_to_target.as_path().to_path_buf(); - preserve_hardlinks(&mut hard_links, &source, dest, &mut found_hard_link).unwrap(); + preserve_hardlinks(&mut hard_links, &source, dest, &mut found_hard_link)?; if !found_hard_link { match copy_file( path.as_path(), diff --git a/src/uu/cp/src/main.rs b/src/uu/cp/src/main.rs index acfcfd1b2..920615e70 100644 --- a/src/uu/cp/src/main.rs +++ b/src/uu/cp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cp); +uucore::bin!(uu_cp); diff --git a/src/uu/csplit/Cargo.toml b/src/uu/csplit/Cargo.toml index 881f9fa55..79927594b 100644 --- a/src/uu/csplit/Cargo.toml +++ b/src/uu/csplit/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } thiserror = "1.0" regex = "1.0.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "csplit" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/csplit/src/csplit.rs b/src/uu/csplit/src/csplit.rs index c5e315100..3d7136dcd 100644 --- a/src/uu/csplit/src/csplit.rs +++ b/src/uu/csplit/src/csplit.rs @@ -717,7 +717,7 @@ mod tests { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let args = args diff --git a/src/uu/csplit/src/main.rs b/src/uu/csplit/src/main.rs index b0b144e8c..1ada30007 100644 --- a/src/uu/csplit/src/main.rs +++ b/src/uu/csplit/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_csplit); +uucore::bin!(uu_csplit); diff --git a/src/uu/cut/Cargo.toml b/src/uu/cut/Cargo.toml index 9d25c5574..dd27fa435 100644 --- a/src/uu/cut/Cargo.toml +++ b/src/uu/cut/Cargo.toml @@ -17,7 +17,6 @@ path = "src/cut.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } memchr = "2" bstr = "0.2" atty = "0.2" @@ -25,6 +24,3 @@ atty = "0.2" [[bin]] name = "cut" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/cut/src/cut.rs b/src/uu/cut/src/cut.rs index 1b793d917..8ad5fd230 100644 --- a/src/uu/cut/src/cut.rs +++ b/src/uu/cut/src/cut.rs @@ -395,7 +395,7 @@ mod options { pub const FILE: &str = "file"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/cut/src/main.rs b/src/uu/cut/src/main.rs index 8822335f6..2f000a7f3 100644 --- a/src/uu/cut/src/main.rs +++ b/src/uu/cut/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_cut); +uucore::bin!(uu_cut); diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index 76c35fcd5..4ca628998 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -18,7 +18,6 @@ path = "src/date.rs" chrono = "^0.4.11" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(unix)'.dependencies] libc = "0.2" @@ -29,6 +28,3 @@ winapi = { version = "0.3", features = ["minwinbase", "sysinfoapi", "minwindef"] [[bin]] name = "date" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index b43244349..49090f0ff 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -140,7 +140,7 @@ impl<'a> From<&'a str> for Rfc3339Format { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let syntax = format!( "{0} [OPTION]... [+FORMAT]... diff --git a/src/uu/date/src/main.rs b/src/uu/date/src/main.rs index 9064c7f67..7483582de 100644 --- a/src/uu/date/src/main.rs +++ b/src/uu/date/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_date); +uucore::bin!(uu_date); diff --git a/src/uu/dd/Cargo.toml b/src/uu/dd/Cargo.toml index de8fc31d5..afb61aded 100644 --- a/src/uu/dd/Cargo.toml +++ b/src/uu/dd/Cargo.toml @@ -20,7 +20,6 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } gcd = "2.0" libc = "0.2" uucore = { version=">=0.0.8", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" } [dev-dependencies] tempfile = "^3" @@ -31,6 +30,3 @@ signal-hook = "0.3.9" [[bin]] name = "dd" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index fe26bd12a..29fe0dccf 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -907,7 +907,7 @@ fn append_dashes_if_not_present(mut acc: Vec, mut s: String) -> Vec UResult<()> { let dashed_args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/dd/src/main.rs b/src/uu/dd/src/main.rs index fb6f5a6f5..267fe5a3e 100644 --- a/src/uu/dd/src/main.rs +++ b/src/uu/dd/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_dd); // spell-checker:ignore procs uucore +uucore::bin!(uu_dd); // spell-checker:ignore procs uucore diff --git a/src/uu/df/Cargo.toml b/src/uu/df/Cargo.toml index d0929f9fa..d3d2fd395 100644 --- a/src/uu/df/Cargo.toml +++ b/src/uu/df/Cargo.toml @@ -18,11 +18,7 @@ path = "src/df.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } number_prefix = "0.4" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "fsext"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "df" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 9f748f4c2..54b39cb15 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -277,7 +277,7 @@ impl UError for DfError { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/df/src/main.rs b/src/uu/df/src/main.rs index a6d403782..3868d685a 100644 --- a/src/uu/df/src/main.rs +++ b/src/uu/df/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_df); +uucore::bin!(uu_df); diff --git a/src/uu/dircolors/Cargo.toml b/src/uu/dircolors/Cargo.toml index 0f752060b..403da5171 100644 --- a/src/uu/dircolors/Cargo.toml +++ b/src/uu/dircolors/Cargo.toml @@ -18,11 +18,7 @@ path = "src/dircolors.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } glob = "0.3.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "dircolors" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index b966a06f6..b0e81f817 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -65,7 +65,7 @@ fn usage() -> String { format!("{0} {1}", uucore::execution_phrase(), SYNTAX) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/dircolors/src/main.rs b/src/uu/dircolors/src/main.rs index a6a820bd9..f8c8d4ea5 100644 --- a/src/uu/dircolors/src/main.rs +++ b/src/uu/dircolors/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_dircolors); +uucore::bin!(uu_dircolors); diff --git a/src/uu/dirname/Cargo.toml b/src/uu/dirname/Cargo.toml index e17ac95ac..9980d31a6 100644 --- a/src/uu/dirname/Cargo.toml +++ b/src/uu/dirname/Cargo.toml @@ -18,7 +18,6 @@ path = "src/dirname.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "dirname" diff --git a/src/uu/dirname/src/dirname.rs b/src/uu/dirname/src/dirname.rs index 677ad025b..4a6a5ad9b 100644 --- a/src/uu/dirname/src/dirname.rs +++ b/src/uu/dirname/src/dirname.rs @@ -29,7 +29,7 @@ fn get_long_usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/dirname/src/main.rs b/src/uu/dirname/src/main.rs index bf923e86a..aa4891134 100644 --- a/src/uu/dirname/src/main.rs +++ b/src/uu/dirname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_dirname); +uucore::bin!(uu_dirname); diff --git a/src/uu/du/Cargo.toml b/src/uu/du/Cargo.toml index 5fd85640b..2fb7a0625 100644 --- a/src/uu/du/Cargo.toml +++ b/src/uu/du/Cargo.toml @@ -18,7 +18,6 @@ path = "src/du.rs" chrono = "^0.4.11" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version="0.3", features=[] } diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 2dbc884a3..d92ead173 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -452,7 +452,7 @@ impl UError for DuError { } } -#[uucore_procs::gen_uumain] +#[uucore::main] #[allow(clippy::cognitive_complexity)] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args diff --git a/src/uu/du/src/main.rs b/src/uu/du/src/main.rs index de9bfc1a5..3d00ad9b5 100644 --- a/src/uu/du/src/main.rs +++ b/src/uu/du/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_du); +uucore::bin!(uu_du); diff --git a/src/uu/echo/Cargo.toml b/src/uu/echo/Cargo.toml index be97527d9..042a1225a 100644 --- a/src/uu/echo/Cargo.toml +++ b/src/uu/echo/Cargo.toml @@ -17,7 +17,6 @@ path = "src/echo.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "echo" diff --git a/src/uu/echo/src/echo.rs b/src/uu/echo/src/echo.rs index 7b8d89f81..db2744804 100644 --- a/src/uu/echo/src/echo.rs +++ b/src/uu/echo/src/echo.rs @@ -111,7 +111,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result { Ok(should_stop) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/echo/src/main.rs b/src/uu/echo/src/main.rs index b8d3b4b32..85747c448 100644 --- a/src/uu/echo/src/main.rs +++ b/src/uu/echo/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_echo); +uucore::bin!(uu_echo); diff --git a/src/uu/env/Cargo.toml b/src/uu/env/Cargo.toml index d6ded5d46..bb43a75bd 100644 --- a/src/uu/env/Cargo.toml +++ b/src/uu/env/Cargo.toml @@ -19,7 +19,6 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" rust-ini = "0.17.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "env" diff --git a/src/uu/env/src/env.rs b/src/uu/env/src/env.rs index dcbcfb9b3..677ffe1bf 100644 --- a/src/uu/env/src/env.rs +++ b/src/uu/env/src/env.rs @@ -319,7 +319,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> { Ok(()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { run_env(args) } diff --git a/src/uu/env/src/main.rs b/src/uu/env/src/main.rs index 9c19a3ab4..662167388 100644 --- a/src/uu/env/src/main.rs +++ b/src/uu/env/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_env); +uucore::bin!(uu_env); diff --git a/src/uu/expand/Cargo.toml b/src/uu/expand/Cargo.toml index 269486184..42a10dabf 100644 --- a/src/uu/expand/Cargo.toml +++ b/src/uu/expand/Cargo.toml @@ -18,11 +18,7 @@ path = "src/expand.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "expand" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index 93dc0e53b..81ebb1269 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -171,7 +171,7 @@ impl Options { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/expand/src/main.rs b/src/uu/expand/src/main.rs index a154b36be..2d88f6187 100644 --- a/src/uu/expand/src/main.rs +++ b/src/uu/expand/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_expand); +uucore::bin!(uu_expand); diff --git a/src/uu/expr/Cargo.toml b/src/uu/expr/Cargo.toml index aac7204e7..87113f84a 100644 --- a/src/uu/expr/Cargo.toml +++ b/src/uu/expr/Cargo.toml @@ -21,11 +21,7 @@ num-bigint = "0.4.0" num-traits = "0.2.14" onig = "~4.3.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "expr" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/expr/src/expr.rs b/src/uu/expr/src/expr.rs index d57ca053c..db0152dd7 100644 --- a/src/uu/expr/src/expr.rs +++ b/src/uu/expr/src/expr.rs @@ -22,7 +22,7 @@ pub fn uu_app<'a>() -> App<'a> { .arg(Arg::new(HELP).long(HELP)) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/expr/src/main.rs b/src/uu/expr/src/main.rs index 6fdd6be14..1a4134906 100644 --- a/src/uu/expr/src/main.rs +++ b/src/uu/expr/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_expr); +uucore::bin!(uu_expr); diff --git a/src/uu/factor/Cargo.toml b/src/uu/factor/Cargo.toml index 9d53cd52a..ae9a0969b 100644 --- a/src/uu/factor/Cargo.toml +++ b/src/uu/factor/Cargo.toml @@ -21,19 +21,14 @@ num-traits = "0.2.13" # Needs at least version 0.2.13 for "OverflowingAdd" rand = { version = "0.8", features = ["small_rng"] } smallvec = "1.7" # TODO(nicoo): Use `union` feature, requires Rust 1.49 or later. uucore = { version = ">=0.0.8", package = "uucore", path = "../../uucore" } -uucore_procs = { version=">=0.0.8", package = "uucore_procs", path = "../../uucore_procs" } [dev-dependencies] paste = "0.1.18" quickcheck = "1.0.3" - [[bin]] name = "factor" path = "src/main.rs" [lib] path = "src/cli.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index ce7924005..90f2fd3c8 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -44,7 +44,7 @@ fn print_factors_str( }) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().get_matches_from(args); let stdout = stdout(); diff --git a/src/uu/factor/src/main.rs b/src/uu/factor/src/main.rs index 4d8b281b6..d091c02cb 100644 --- a/src/uu/factor/src/main.rs +++ b/src/uu/factor/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_factor); +uucore::bin!(uu_factor); diff --git a/src/uu/false/Cargo.toml b/src/uu/false/Cargo.toml index cc7e9c517..7ac5602b7 100644 --- a/src/uu/false/Cargo.toml +++ b/src/uu/false/Cargo.toml @@ -17,7 +17,6 @@ path = "src/false.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "false" diff --git a/src/uu/false/src/false.rs b/src/uu/false/src/false.rs index a75770728..324f90579 100644 --- a/src/uu/false/src/false.rs +++ b/src/uu/false/src/false.rs @@ -8,7 +8,7 @@ use clap::App; use uucore::error::UResult; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { uu_app().get_matches_from(args); Err(1.into()) diff --git a/src/uu/false/src/main.rs b/src/uu/false/src/main.rs index 382a16fc7..3b46ec126 100644 --- a/src/uu/false/src/main.rs +++ b/src/uu/false/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_false); +uucore::bin!(uu_false); diff --git a/src/uu/fmt/Cargo.toml b/src/uu/fmt/Cargo.toml index 6b6f551ca..b86c94d86 100644 --- a/src/uu/fmt/Cargo.toml +++ b/src/uu/fmt/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "fmt" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/fmt/src/fmt.rs b/src/uu/fmt/src/fmt.rs index 5cf4c5758..b3ca61dd5 100644 --- a/src/uu/fmt/src/fmt.rs +++ b/src/uu/fmt/src/fmt.rs @@ -66,7 +66,7 @@ pub struct FmtOptions { tabwidth: usize, } -#[uucore_procs::gen_uumain] +#[uucore::main] #[allow(clippy::cognitive_complexity)] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/fmt/src/main.rs b/src/uu/fmt/src/main.rs index 35531a8b4..7d9bcbd4d 100644 --- a/src/uu/fmt/src/main.rs +++ b/src/uu/fmt/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_fmt); +uucore::bin!(uu_fmt); diff --git a/src/uu/fold/Cargo.toml b/src/uu/fold/Cargo.toml index e08a59cd3..b177eb4f7 100644 --- a/src/uu/fold/Cargo.toml +++ b/src/uu/fold/Cargo.toml @@ -17,11 +17,7 @@ path = "src/fold.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "fold" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/fold/src/fold.rs b/src/uu/fold/src/fold.rs index f52389942..0fcaf30b8 100644 --- a/src/uu/fold/src/fold.rs +++ b/src/uu/fold/src/fold.rs @@ -29,7 +29,7 @@ mod options { pub const FILE: &str = "file"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/fold/src/main.rs b/src/uu/fold/src/main.rs index 1802f2cf8..7658a5d01 100644 --- a/src/uu/fold/src/main.rs +++ b/src/uu/fold/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_fold); +uucore::bin!(uu_fold); diff --git a/src/uu/groups/Cargo.toml b/src/uu/groups/Cargo.toml index ca0fe74f6..93b67ba43 100644 --- a/src/uu/groups/Cargo.toml +++ b/src/uu/groups/Cargo.toml @@ -17,11 +17,7 @@ path = "src/groups.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "groups" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/groups/src/groups.rs b/src/uu/groups/src/groups.rs index d53f3dfdc..3188f13d5 100644 --- a/src/uu/groups/src/groups.rs +++ b/src/uu/groups/src/groups.rs @@ -69,7 +69,7 @@ fn infallible_gid2grp(gid: &u32) -> String { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/groups/src/main.rs b/src/uu/groups/src/main.rs index 6efe64b54..477194fa0 100644 --- a/src/uu/groups/src/main.rs +++ b/src/uu/groups/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_groups); +uucore::bin!(uu_groups); diff --git a/src/uu/hashsum/Cargo.toml b/src/uu/hashsum/Cargo.toml index 5ce5fa8f6..1d1c89d58 100644 --- a/src/uu/hashsum/Cargo.toml +++ b/src/uu/hashsum/Cargo.toml @@ -28,11 +28,7 @@ sha2 = "0.6.0" sha3 = "0.6.0" blake2b_simd = "0.5.11" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "hashsum" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/hashsum/src/hashsum.rs b/src/uu/hashsum/src/hashsum.rs index d7b782f8f..82f485875 100644 --- a/src/uu/hashsum/src/hashsum.rs +++ b/src/uu/hashsum/src/hashsum.rs @@ -274,7 +274,7 @@ fn is_valid_bit_num(arg: &str) -> Result<(), String> { parse_bit_num(arg).map(|_| ()).map_err(|e| format!("{}", e)) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { // if there is no program name for some reason, default to "hashsum" let program = args.next().unwrap_or_else(|| OsString::from(NAME)); diff --git a/src/uu/hashsum/src/main.rs b/src/uu/hashsum/src/main.rs index bc4e2f3be..c31d4a9af 100644 --- a/src/uu/hashsum/src/main.rs +++ b/src/uu/hashsum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hashsum); +uucore::bin!(uu_hashsum); diff --git a/src/uu/head/Cargo.toml b/src/uu/head/Cargo.toml index db44ec51f..5d05f1921 100644 --- a/src/uu/head/Cargo.toml +++ b/src/uu/head/Cargo.toml @@ -18,11 +18,7 @@ path = "src/head.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } memchr = "2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "head" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/head/src/head.rs b/src/uu/head/src/head.rs index 53ae449ce..5c222657b 100644 --- a/src/uu/head/src/head.rs +++ b/src/uu/head/src/head.rs @@ -485,7 +485,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> { Ok(()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = match HeadOptions::get_from(args) { Ok(o) => o, diff --git a/src/uu/head/src/main.rs b/src/uu/head/src/main.rs index 3e66a50d0..850a725e4 100644 --- a/src/uu/head/src/main.rs +++ b/src/uu/head/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_head); +uucore::bin!(uu_head); diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index 99afcc075..309671a29 100644 --- a/src/uu/hostid/Cargo.toml +++ b/src/uu/hostid/Cargo.toml @@ -18,7 +18,6 @@ path = "src/hostid.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "hostid" diff --git a/src/uu/hostid/src/hostid.rs b/src/uu/hostid/src/hostid.rs index 80742408b..764b7d279 100644 --- a/src/uu/hostid/src/hostid.rs +++ b/src/uu/hostid/src/hostid.rs @@ -18,7 +18,7 @@ extern "C" { pub fn gethostid() -> c_long; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { uu_app().get_matches_from(args); hostid(); diff --git a/src/uu/hostid/src/main.rs b/src/uu/hostid/src/main.rs index 9645ed4a6..de9e22fbf 100644 --- a/src/uu/hostid/src/main.rs +++ b/src/uu/hostid/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hostid); +uucore::bin!(uu_hostid); diff --git a/src/uu/hostname/Cargo.toml b/src/uu/hostname/Cargo.toml index 4402ae41b..55fc064f3 100644 --- a/src/uu/hostname/Cargo.toml +++ b/src/uu/hostname/Cargo.toml @@ -19,7 +19,6 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" hostname = { version = "0.3", features = ["set"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } winapi = { version="0.3", features=["sysinfoapi", "winsock2"] } [[bin]] diff --git a/src/uu/hostname/src/hostname.rs b/src/uu/hostname/src/hostname.rs index 67fe508af..902b9714e 100644 --- a/src/uu/hostname/src/hostname.rs +++ b/src/uu/hostname/src/hostname.rs @@ -58,7 +58,7 @@ fn usage() -> String { format!("{0} [OPTION]... [HOSTNAME]", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/hostname/src/main.rs b/src/uu/hostname/src/main.rs index 1d6e6733e..09058e44a 100644 --- a/src/uu/hostname/src/main.rs +++ b/src/uu/hostname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_hostname); +uucore::bin!(uu_hostname); diff --git a/src/uu/id/Cargo.toml b/src/uu/id/Cargo.toml index 41397f078..b611e1e91 100644 --- a/src/uu/id/Cargo.toml +++ b/src/uu/id/Cargo.toml @@ -17,7 +17,6 @@ path = "src/id.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "process"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } selinux = { version="0.2", optional = true } [[bin]] diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 66ac4f571..293be0b49 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -126,7 +126,7 @@ struct State { user_specified: bool, } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let after_help = get_description(); diff --git a/src/uu/id/src/main.rs b/src/uu/id/src/main.rs index c8f6fe6aa..21a7a8514 100644 --- a/src/uu/id/src/main.rs +++ b/src/uu/id/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_id); +uucore::bin!(uu_id); diff --git a/src/uu/install/Cargo.toml b/src/uu/install/Cargo.toml index d02d4a8b9..d00655e8b 100644 --- a/src/uu/install/Cargo.toml +++ b/src/uu/install/Cargo.toml @@ -23,7 +23,6 @@ filetime = "0.2" file_diff = "1.0.0" libc = ">= 0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode", "perms", "entries"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [dev-dependencies] time = "0.1.40" diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index ec423f161..9aca5fb64 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -171,7 +171,7 @@ fn usage() -> String { /// /// Returns a program return code. /// -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/install/src/main.rs b/src/uu/install/src/main.rs index d296ec4a2..993acae6a 100644 --- a/src/uu/install/src/main.rs +++ b/src/uu/install/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_install); +uucore::bin!(uu_install); diff --git a/src/uu/join/Cargo.toml b/src/uu/join/Cargo.toml index 2f3b6d462..b4150b4be 100644 --- a/src/uu/join/Cargo.toml +++ b/src/uu/join/Cargo.toml @@ -17,11 +17,7 @@ path = "src/join.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "join" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 1f784a91c..be664be82 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -503,7 +503,7 @@ impl<'a> State<'a> { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().get_matches_from(args); diff --git a/src/uu/join/src/main.rs b/src/uu/join/src/main.rs index 5114252cd..7520de6d7 100644 --- a/src/uu/join/src/main.rs +++ b/src/uu/join/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_join); +uucore::bin!(uu_join); diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index 400dbbc8f..42c90b89f 100644 --- a/src/uu/kill/Cargo.toml +++ b/src/uu/kill/Cargo.toml @@ -18,7 +18,6 @@ path = "src/kill.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["signals"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "kill" diff --git a/src/uu/kill/src/kill.rs b/src/uu/kill/src/kill.rs index 9c76038fe..02dc91dbf 100644 --- a/src/uu/kill/src/kill.rs +++ b/src/uu/kill/src/kill.rs @@ -35,7 +35,7 @@ pub enum Mode { List, } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let mut args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/kill/src/main.rs b/src/uu/kill/src/main.rs index 91d0a28f0..6f3fbac47 100644 --- a/src/uu/kill/src/main.rs +++ b/src/uu/kill/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_kill); +uucore::bin!(uu_kill); diff --git a/src/uu/link/Cargo.toml b/src/uu/link/Cargo.toml index dc544e94e..aef64847e 100644 --- a/src/uu/link/Cargo.toml +++ b/src/uu/link/Cargo.toml @@ -18,11 +18,7 @@ path = "src/link.rs" libc = "0.2.42" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "link" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index 1ddf83bc1..d20bf3b03 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -20,7 +20,7 @@ fn usage() -> String { format!("{0} FILE1 FILE2", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/link/src/main.rs b/src/uu/link/src/main.rs index ccc565fed..8c4e653f4 100644 --- a/src/uu/link/src/main.rs +++ b/src/uu/link/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_link); +uucore::bin!(uu_link); diff --git a/src/uu/ln/Cargo.toml b/src/uu/ln/Cargo.toml index cfa19d6a3..6d268408a 100644 --- a/src/uu/ln/Cargo.toml +++ b/src/uu/ln/Cargo.toml @@ -18,7 +18,6 @@ path = "src/ln.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "ln" diff --git a/src/uu/ln/src/ln.rs b/src/uu/ln/src/ln.rs index d9370773d..cd2dde5fd 100644 --- a/src/uu/ln/src/ln.rs +++ b/src/uu/ln/src/ln.rs @@ -129,7 +129,7 @@ mod options { static ARG_FILES: &str = "files"; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let long_usage = long_usage(); diff --git a/src/uu/ln/src/main.rs b/src/uu/ln/src/main.rs index 060001972..c59835fc3 100644 --- a/src/uu/ln/src/main.rs +++ b/src/uu/ln/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ln); +uucore::bin!(uu_ln); diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index 67c24c257..5a109491e 100644 --- a/src/uu/logname/Cargo.toml +++ b/src/uu/logname/Cargo.toml @@ -18,11 +18,7 @@ path = "src/logname.rs" libc = "0.2.42" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "logname" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/logname/src/logname.rs b/src/uu/logname/src/logname.rs index 7166603db..c9c8ca447 100644 --- a/src/uu/logname/src/logname.rs +++ b/src/uu/logname/src/logname.rs @@ -39,7 +39,7 @@ fn usage() -> &'static str { uucore::execution_phrase() } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/logname/src/main.rs b/src/uu/logname/src/main.rs index f9cf6160e..ef5d7d46d 100644 --- a/src/uu/logname/src/main.rs +++ b/src/uu/logname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_logname); +uucore::bin!(uu_logname); diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index d5b2f2ffd..ed38712be 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -24,7 +24,6 @@ termsize = "0.1.6" glob = "0.3.0" lscolors = { version = "0.7.1", features = ["ansi_term"] } uucore = { version = ">=0.0.8", package = "uucore", path = "../../uucore", features = ["entries", "fs"] } -uucore_procs = { version=">=0.0.8", package = "uucore_procs", path = "../../uucore_procs" } once_cell = "1.7.2" atty = "0.2" selinux = { version="0.2", optional = true } @@ -38,6 +37,3 @@ path = "src/main.rs" [features] feat_selinux = ["selinux"] - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index b619adc3a..2647e77ba 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -21,7 +21,6 @@ use lscolors::LsColors; use number_prefix::NumberPrefix; use once_cell::unsync::OnceCell; use quoting_style::{escape_name, QuotingStyle}; -use std::ffi::OsString; #[cfg(windows)] use std::os::windows::fs::MetadataExt; use std::{ @@ -39,6 +38,7 @@ use std::{ os::unix::fs::{FileTypeExt, MetadataExt}, time::Duration, }; +use std::{ffi::OsString, fs::ReadDir}; use term_grid::{Cell, Direction, Filling, Grid, GridOptions}; use uucore::{ display::Quotable, @@ -165,7 +165,7 @@ impl Display for LsError { LsError::IOError(e) => write!(f, "general io error: {}", e), LsError::IOErrorContext(e, p) => { let error_kind = e.kind(); - let raw_os_error = e.raw_os_error().unwrap_or(13i32); + let errno = e.raw_os_error().unwrap_or(1i32); match error_kind { // No such file or directory @@ -180,7 +180,7 @@ impl Display for LsError { ErrorKind::PermissionDenied => { #[allow(clippy::wildcard_in_or_patterns)] - match raw_os_error { + match errno { 1i32 => { write!( f, @@ -205,12 +205,24 @@ impl Display for LsError { } } } - _ => write!( - f, - "unknown io error: '{:?}', '{:?}'", - p.to_string_lossy(), - e - ), + _ => match errno { + 9i32 => { + // only should ever occur on a read_dir on a bad fd + write!( + f, + "cannot open directory '{}': Bad file descriptor", + p.to_string_lossy(), + ) + } + _ => { + write!( + f, + "unknown io error: '{:?}', '{:?}'", + p.to_string_lossy(), + e + ) + } + }, } } } @@ -683,7 +695,7 @@ impl Config { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); @@ -1272,6 +1284,7 @@ struct PathData { // Result got from symlink_metadata() or metadata() based on config md: OnceCell>, ft: OnceCell>, + de: Option, // Name of the file - will be empty for . or .. display_name: OsString, // PathBuf that all above data corresponds to @@ -1283,7 +1296,7 @@ struct PathData { impl PathData { fn new( p_buf: PathBuf, - file_type: Option>, + dir_entry: Option>, file_name: Option, config: &Config, command_line: bool, @@ -1317,8 +1330,23 @@ impl PathData { Dereference::None => false, }; - let ft = match file_type { - Some(ft) => OnceCell::from(ft.ok()), + let de: Option = match dir_entry { + Some(de) => de.ok(), + None => None, + }; + + // Why prefer to check the DirEntry file_type()? B/c the call is + // nearly free compared to a metadata() call on a Path + let ft = match de { + Some(ref de) => { + if let Ok(ft_de) = de.file_type() { + OnceCell::from(Some(ft_de)) + } else if let Ok(md_pb) = p_buf.metadata() { + OnceCell::from(Some(md_pb.file_type())) + } else { + OnceCell::new() + } + } None => OnceCell::new(), }; @@ -1331,6 +1359,7 @@ impl PathData { Self { md: OnceCell::new(), ft, + de, display_name, p_buf, must_dereference, @@ -1340,16 +1369,34 @@ impl PathData { fn md(&self, out: &mut BufWriter) -> Option<&Metadata> { self.md - .get_or_init( - || match get_metadata(self.p_buf.as_path(), self.must_dereference) { + .get_or_init(|| { + // check if we can use DirEntry metadata + if !self.must_dereference { + if let Some(dir_entry) = &self.de { + return dir_entry.metadata().ok(); + } + } + + // if not, check if we can use Path metadata + match get_metadata(self.p_buf.as_path(), self.must_dereference) { Err(err) => { let _ = out.flush(); + let errno = err.raw_os_error().unwrap_or(1i32); + // a bad fd will throw an error when dereferenced, + // but GNU will not throw an error until a bad fd "dir" + // is entered, here we match that GNU behavior, by handing + // back the non-dereferenced metadata upon an EBADF + if self.must_dereference && errno == 9i32 { + if let Some(dir_entry) = &self.de { + return dir_entry.metadata().ok(); + } + } show!(LsError::IOErrorContext(err, self.p_buf.clone(),)); None } Ok(md) => Some(md), - }, - ) + } + }) .as_ref() } @@ -1399,16 +1446,28 @@ fn list(locs: Vec<&Path>, config: Config) -> UResult<()> { display_items(&files, &config, &mut out); - for (pos, dir) in dirs.iter().enumerate() { + for (pos, path_data) in dirs.iter().enumerate() { + // Do read_dir call here to match GNU semantics by printing + // read_dir errors before directory headings, names and totals + let read_dir = match fs::read_dir(&path_data.p_buf) { + Err(err) => { + // flush stdout buffer before the error to preserve formatting and order + let _ = out.flush(); + show!(LsError::IOErrorContext(err, path_data.p_buf.clone())); + continue; + } + Ok(rd) => rd, + }; + // Print dir heading - name... 'total' comes after error display if initial_locs_len > 1 || config.recursive { if pos.eq(&0usize) && files.is_empty() { - let _ = writeln!(out, "{}:", dir.p_buf.display()); + let _ = writeln!(out, "{}:", path_data.p_buf.display()); } else { - let _ = writeln!(out, "\n{}:", dir.p_buf.display()); + let _ = writeln!(out, "\n{}:", path_data.p_buf.display()); } } - enter_directory(dir, &config, &mut out); + enter_directory(path_data, read_dir, &config, &mut out); } Ok(()) @@ -1477,12 +1536,29 @@ fn should_display(entry: &DirEntry, config: &Config) -> bool { true } -fn enter_directory(dir: &PathData, config: &Config, out: &mut BufWriter) { +fn enter_directory( + path_data: &PathData, + read_dir: ReadDir, + config: &Config, + out: &mut BufWriter, +) { // Create vec of entries with initial dot files let mut entries: Vec = if config.files == Files::All { vec![ - PathData::new(dir.p_buf.clone(), None, Some(".".into()), config, false), - PathData::new(dir.p_buf.join(".."), None, Some("..".into()), config, false), + PathData::new( + path_data.p_buf.clone(), + None, + Some(".".into()), + config, + false, + ), + PathData::new( + path_data.p_buf.join(".."), + None, + Some("..".into()), + config, + false, + ), ] } else { vec![] @@ -1491,19 +1567,8 @@ fn enter_directory(dir: &PathData, config: &Config, out: &mut BufWriter) // Convert those entries to the PathData struct let mut vec_path_data = Vec::new(); - // check for errors early, and ignore entries with errors - let read_dir = match fs::read_dir(&dir.p_buf) { - Err(err) => { - // flush buffer because the error may get printed in the wrong order - let _ = out.flush(); - show!(LsError::IOErrorContext(err, dir.p_buf.clone())); - return; - } - Ok(res) => res, - }; - - for entry in read_dir { - let unwrapped = match entry { + for raw_entry in read_dir { + let dir_entry = match raw_entry { Ok(path) => path, Err(err) => { let _ = out.flush(); @@ -1512,27 +1577,17 @@ fn enter_directory(dir: &PathData, config: &Config, out: &mut BufWriter) } }; - if should_display(&unwrapped, config) { - // why check the DirEntry file_type()? B/c the call is - // nearly free compared to a metadata() or file_type() call on a dir/file - let path_data = match unwrapped.file_type() { - Err(err) => { - let _ = out.flush(); - show!(LsError::IOErrorContext(err, unwrapped.path())); - continue; - } - Ok(dir_ft) => { - PathData::new(unwrapped.path(), Some(Ok(dir_ft)), None, config, false) - } - }; - vec_path_data.push(path_data); + if should_display(&dir_entry, config) { + let entry_path_data = + PathData::new(dir_entry.path(), Some(Ok(dir_entry)), None, config, false); + vec_path_data.push(entry_path_data); }; } sort_entries(&mut vec_path_data, config, out); entries.append(&mut vec_path_data); - // ...and total + // Print total after any error display if config.format == Format::Long { display_total(&entries, config, out); } @@ -1543,13 +1598,21 @@ fn enter_directory(dir: &PathData, config: &Config, out: &mut BufWriter) for e in entries .iter() .skip(if config.files == Files::All { 2 } else { 0 }) - // Already requested file_type for the dir_entries above. So we know the OnceCell is set. - // And can unwrap again because we tested whether path has is_some here + .filter(|p| p.ft.get().is_some()) .filter(|p| p.ft.get().unwrap().is_some()) .filter(|p| p.ft.get().unwrap().unwrap().is_dir()) { - let _ = writeln!(out, "\n{}:", e.p_buf.display()); - enter_directory(e, config, out); + match fs::read_dir(&e.p_buf) { + Err(err) => { + let _ = out.flush(); + show!(LsError::IOErrorContext(err, e.p_buf.clone())); + continue; + } + Ok(rd) => { + let _ = writeln!(out, "\n{}:", e.p_buf.display()); + enter_directory(e, rd, config, out); + } + } } } } @@ -1973,10 +2036,43 @@ fn display_item_long( } } + #[cfg(unix)] + let leading_char = { + if let Some(Some(ft)) = item.ft.get() { + if ft.is_char_device() { + "c" + } else if ft.is_block_device() { + "b" + } else if ft.is_symlink() { + "l" + } else if ft.is_dir() { + "d" + } else { + "-" + } + } else { + "-" + } + }; + #[cfg(not(unix))] + let leading_char = { + if let Some(Some(ft)) = item.ft.get() { + if ft.is_symlink() { + "l" + } else if ft.is_dir() { + "d" + } else { + "-" + } + } else { + "-" + } + }; + let _ = write!( out, "{}{} {}", - "l?????????", + format_args!("{}?????????", leading_char), if item.security_context.len() > 1 { // GNU `ls` uses a "." character to indicate a file with a security context, // but not other alternate access method. diff --git a/src/uu/ls/src/main.rs b/src/uu/ls/src/main.rs index d867c3843..c2a935e6d 100644 --- a/src/uu/ls/src/main.rs +++ b/src/uu/ls/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ls); +uucore::bin!(uu_ls); diff --git a/src/uu/mkdir/Cargo.toml b/src/uu/mkdir/Cargo.toml index 519aa9113..a984367be 100644 --- a/src/uu/mkdir/Cargo.toml +++ b/src/uu/mkdir/Cargo.toml @@ -18,7 +18,6 @@ path = "src/mkdir.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "mkdir" diff --git a/src/uu/mkdir/src/main.rs b/src/uu/mkdir/src/main.rs index fa6855c93..e3ea12f79 100644 --- a/src/uu/mkdir/src/main.rs +++ b/src/uu/mkdir/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mkdir); +uucore::bin!(uu_mkdir); diff --git a/src/uu/mkdir/src/mkdir.rs b/src/uu/mkdir/src/mkdir.rs index afa30861c..377036174 100644 --- a/src/uu/mkdir/src/mkdir.rs +++ b/src/uu/mkdir/src/mkdir.rs @@ -78,7 +78,7 @@ fn strip_minus_from_mode(args: &mut Vec) -> bool { mode::strip_minus_from_mode(args) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let mut args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index 971b20f45..3a61c55a5 100644 --- a/src/uu/mkfifo/Cargo.toml +++ b/src/uu/mkfifo/Cargo.toml @@ -18,11 +18,7 @@ path = "src/mkfifo.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "mkfifo" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/mkfifo/src/main.rs b/src/uu/mkfifo/src/main.rs index 3ad5a3bed..b803f2c6f 100644 --- a/src/uu/mkfifo/src/main.rs +++ b/src/uu/mkfifo/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mkfifo); +uucore::bin!(uu_mkfifo); diff --git a/src/uu/mkfifo/src/mkfifo.rs b/src/uu/mkfifo/src/mkfifo.rs index 2051140de..fcd26bc8f 100644 --- a/src/uu/mkfifo/src/mkfifo.rs +++ b/src/uu/mkfifo/src/mkfifo.rs @@ -25,7 +25,7 @@ mod options { pub static FIFO: &str = "fifo"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index ab03a08e8..7af88e7b5 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -19,11 +19,7 @@ path = "src/mknod.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "^0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "mknod" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/mknod/src/main.rs b/src/uu/mknod/src/main.rs index b65a20cd4..cfb4f1982 100644 --- a/src/uu/mknod/src/main.rs +++ b/src/uu/mknod/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mknod); +uucore::bin!(uu_mknod); diff --git a/src/uu/mknod/src/mknod.rs b/src/uu/mknod/src/mknod.rs index 869d1122c..0ea473a23 100644 --- a/src/uu/mknod/src/mknod.rs +++ b/src/uu/mknod/src/mknod.rs @@ -79,7 +79,7 @@ fn _mknod(file_name: &str, mode: mode_t, dev: dev_t) -> i32 { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/mktemp/Cargo.toml b/src/uu/mktemp/Cargo.toml index dc4b28329..95ab09aa6 100644 --- a/src/uu/mktemp/Cargo.toml +++ b/src/uu/mktemp/Cargo.toml @@ -19,7 +19,6 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } rand = "0.8" tempfile = "3.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "mktemp" diff --git a/src/uu/mktemp/src/main.rs b/src/uu/mktemp/src/main.rs index 020284655..4fb826ebb 100644 --- a/src/uu/mktemp/src/main.rs +++ b/src/uu/mktemp/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mktemp); +uucore::bin!(uu_mktemp); diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 1eb2d9f17..e0679a3e4 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -74,7 +74,7 @@ impl Display for MkTempError { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/more/Cargo.toml b/src/uu/more/Cargo.toml index 068443906..067dfe8c2 100644 --- a/src/uu/more/Cargo.toml +++ b/src/uu/more/Cargo.toml @@ -17,7 +17,6 @@ path = "src/more.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.7", package = "uucore", path = "../../uucore" } -uucore_procs = { version=">=0.0.8", package = "uucore_procs", path = "../../uucore_procs" } crossterm = ">=0.19" atty = "0.2" unicode-width = "0.1.7" @@ -33,6 +32,3 @@ nix = "0.23.1" [[bin]] name = "more" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/more/src/main.rs b/src/uu/more/src/main.rs index 15fbf51f9..d0c3c3e23 100644 --- a/src/uu/more/src/main.rs +++ b/src/uu/more/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_more); +uucore::bin!(uu_more); diff --git a/src/uu/more/src/more.rs b/src/uu/more/src/more.rs index 61f3868cf..db6ad249b 100644 --- a/src/uu/more/src/more.rs +++ b/src/uu/more/src/more.rs @@ -49,7 +49,7 @@ pub mod options { const MULTI_FILE_TOP_PROMPT: &str = "::::::::::::::\n{}\n::::::::::::::\n"; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().get_matches_from(args); diff --git a/src/uu/mv/Cargo.toml b/src/uu/mv/Cargo.toml index dd43819bf..fdce84366 100644 --- a/src/uu/mv/Cargo.toml +++ b/src/uu/mv/Cargo.toml @@ -18,11 +18,7 @@ path = "src/mv.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } fs_extra = "1.1.0" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "mv" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/mv/src/main.rs b/src/uu/mv/src/main.rs index 49f7956e8..d0abc28c1 100644 --- a/src/uu/mv/src/main.rs +++ b/src/uu/mv/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_mv); +uucore::bin!(uu_mv); diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 005cc4320..be305d82c 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -72,7 +72,7 @@ fn usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index 6b72b35f3..db95dc99a 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" nix = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "nice" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/nice/src/main.rs b/src/uu/nice/src/main.rs index 039f40d9d..7e7f23792 100644 --- a/src/uu/nice/src/main.rs +++ b/src/uu/nice/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nice); +uucore::bin!(uu_nice); diff --git a/src/uu/nice/src/nice.rs b/src/uu/nice/src/nice.rs index 91bf585be..65b610f42 100644 --- a/src/uu/nice/src/nice.rs +++ b/src/uu/nice/src/nice.rs @@ -36,7 +36,7 @@ process).", ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/nl/Cargo.toml b/src/uu/nl/Cargo.toml index e6861c804..9817cf6f8 100644 --- a/src/uu/nl/Cargo.toml +++ b/src/uu/nl/Cargo.toml @@ -22,11 +22,7 @@ memchr = "2.2.0" regex = "1.0.1" regex-syntax = "0.6.7" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "nl" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/nl/src/main.rs b/src/uu/nl/src/main.rs index 072fad504..3b66630fa 100644 --- a/src/uu/nl/src/main.rs +++ b/src/uu/nl/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nl); +uucore::bin!(uu_nl); diff --git a/src/uu/nl/src/nl.rs b/src/uu/nl/src/nl.rs index 5c322e14f..827339720 100644 --- a/src/uu/nl/src/nl.rs +++ b/src/uu/nl/src/nl.rs @@ -81,7 +81,7 @@ pub mod options { pub const NUMBER_WIDTH: &str = "number-width"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index a735f72db..13551a361 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "nohup" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/nohup/src/main.rs b/src/uu/nohup/src/main.rs index 2007711f6..0d197bbf2 100644 --- a/src/uu/nohup/src/main.rs +++ b/src/uu/nohup/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nohup); +uucore::bin!(uu_nohup); diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 0778bb22d..0b5392ef2 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -81,7 +81,7 @@ impl Display for NohupError { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let args = args diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index 608994bf7..cded0c381 100644 --- a/src/uu/nproc/Cargo.toml +++ b/src/uu/nproc/Cargo.toml @@ -19,11 +19,7 @@ libc = "0.2.42" num_cpus = "1.10" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "nproc" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/nproc/src/main.rs b/src/uu/nproc/src/main.rs index 356c2101f..71853dd03 100644 --- a/src/uu/nproc/src/main.rs +++ b/src/uu/nproc/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_nproc); +uucore::bin!(uu_nproc); diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index 50ebc0f09..18778c27d 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -30,7 +30,7 @@ fn usage() -> String { format!("{0} [OPTIONS]...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/numfmt/Cargo.toml b/src/uu/numfmt/Cargo.toml index b4954884d..336513b55 100644 --- a/src/uu/numfmt/Cargo.toml +++ b/src/uu/numfmt/Cargo.toml @@ -17,11 +17,7 @@ path = "src/numfmt.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "numfmt" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/numfmt/src/main.rs b/src/uu/numfmt/src/main.rs index f4d991727..753e56252 100644 --- a/src/uu/numfmt/src/main.rs +++ b/src/uu/numfmt/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_numfmt); +uucore::bin!(uu_numfmt); diff --git a/src/uu/numfmt/src/numfmt.rs b/src/uu/numfmt/src/numfmt.rs index 81badb043..189bc945c 100644 --- a/src/uu/numfmt/src/numfmt.rs +++ b/src/uu/numfmt/src/numfmt.rs @@ -164,7 +164,7 @@ fn parse_options(args: &ArgMatches) -> Result { }) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/od/Cargo.toml b/src/uu/od/Cargo.toml index 1ab4e7051..3da001265 100644 --- a/src/uu/od/Cargo.toml +++ b/src/uu/od/Cargo.toml @@ -20,11 +20,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } half = "1.6" libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "od" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/od/src/main.rs b/src/uu/od/src/main.rs index 3f30d15e8..d8e0b2c8c 100644 --- a/src/uu/od/src/main.rs +++ b/src/uu/od/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_od); +uucore::bin!(uu_od); diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index d89bcbf39..ad3fad5e9 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -248,7 +248,7 @@ impl OdOptions { /// parses and validates command line parameters, prepares data structures, /// opens the input and calls `odfunc` to process the input. -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/paste/Cargo.toml b/src/uu/paste/Cargo.toml index 87ac9ab20..0a6728ca7 100644 --- a/src/uu/paste/Cargo.toml +++ b/src/uu/paste/Cargo.toml @@ -17,11 +17,7 @@ path = "src/paste.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "paste" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/paste/src/main.rs b/src/uu/paste/src/main.rs index 1d4458b9e..00b99bc6b 100644 --- a/src/uu/paste/src/main.rs +++ b/src/uu/paste/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_paste); +uucore::bin!(uu_paste); diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index 26eeb1aee..4bf2a4417 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -34,7 +34,7 @@ fn read_line( } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().get_matches_from(args); diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index 09f0b133d..d9469d49e 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -18,11 +18,7 @@ path = "src/pathchk.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "pathchk" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/pathchk/src/main.rs b/src/uu/pathchk/src/main.rs index 2b7c3b3ee..6a2a0b945 100644 --- a/src/uu/pathchk/src/main.rs +++ b/src/uu/pathchk/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pathchk); +uucore::bin!(uu_pathchk); diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index bfe16b9ac..df77c42f6 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -40,7 +40,7 @@ fn usage() -> String { format!("{0} [OPTION]... NAME...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let args = args diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index b07a39aa1..05fa71eba 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -17,11 +17,7 @@ path = "src/pinky.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx", "entries"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "pinky" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/pinky/src/main.rs b/src/uu/pinky/src/main.rs index 5414c42cc..8826e60a0 100644 --- a/src/uu/pinky/src/main.rs +++ b/src/uu/pinky/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pinky); +uucore::bin!(uu_pinky); diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 975e2783a..274976075 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -51,7 +51,7 @@ fn get_long_usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/pr/Cargo.toml b/src/uu/pr/Cargo.toml index 63c444e5c..a1fdae4a2 100644 --- a/src/uu/pr/Cargo.toml +++ b/src/uu/pr/Cargo.toml @@ -17,7 +17,6 @@ path = "src/pr.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.7", package="uucore", path="../../uucore", features=["entries"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } getopts = "0.2.21" chrono = "0.4.19" quick-error = "2.0.1" @@ -27,6 +26,3 @@ regex = "1.0" [[bin]] name = "pr" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/pr/src/main.rs b/src/uu/pr/src/main.rs index 893145c3e..faa7a8114 100644 --- a/src/uu/pr/src/main.rs +++ b/src/uu/pr/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pr); // spell-checker:ignore procs uucore +uucore::bin!(uu_pr); // spell-checker:ignore procs uucore diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index aaccef485..601851ed8 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -175,7 +175,7 @@ pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()).setting(AppSettings::InferLongArgs) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(uucore::InvalidEncodingHandling::Ignore) diff --git a/src/uu/printenv/Cargo.toml b/src/uu/printenv/Cargo.toml index b43012700..fbc5094dc 100644 --- a/src/uu/printenv/Cargo.toml +++ b/src/uu/printenv/Cargo.toml @@ -17,11 +17,7 @@ path = "src/printenv.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "printenv" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/printenv/src/main.rs b/src/uu/printenv/src/main.rs index b61cbe90a..fcf429776 100644 --- a/src/uu/printenv/src/main.rs +++ b/src/uu/printenv/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_printenv); +uucore::bin!(uu_printenv); diff --git a/src/uu/printenv/src/printenv.rs b/src/uu/printenv/src/printenv.rs index fe39437e2..e01f66020 100644 --- a/src/uu/printenv/src/printenv.rs +++ b/src/uu/printenv/src/printenv.rs @@ -21,7 +21,7 @@ fn usage() -> String { format!("{0} [VARIABLE]... [OPTION]...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/printf/Cargo.toml b/src/uu/printf/Cargo.toml index 5a14e2465..da49875fb 100644 --- a/src/uu/printf/Cargo.toml +++ b/src/uu/printf/Cargo.toml @@ -25,6 +25,3 @@ uucore = { version = ">=0.0.11", package = "uucore", path = "../../uucore", feat [[bin]] name = "printf" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/printf/src/main.rs b/src/uu/printf/src/main.rs index 9def7dafe..7bb4ae74d 100644 --- a/src/uu/printf/src/main.rs +++ b/src/uu/printf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_printf); +uucore::bin!(uu_printf); diff --git a/src/uu/printf/src/printf.rs b/src/uu/printf/src/printf.rs index 55b3b7d07..1e6c5fbd3 100644 --- a/src/uu/printf/src/printf.rs +++ b/src/uu/printf/src/printf.rs @@ -271,7 +271,7 @@ COPYRIGHT : "; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/ptx/Cargo.toml b/src/uu/ptx/Cargo.toml index 33d6d46cd..6493cafb0 100644 --- a/src/uu/ptx/Cargo.toml +++ b/src/uu/ptx/Cargo.toml @@ -22,11 +22,7 @@ memchr = "2.2.0" regex = "1.0.1" regex-syntax = "0.6.7" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "ptx" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/ptx/src/main.rs b/src/uu/ptx/src/main.rs index b627b801f..926e5f2dd 100644 --- a/src/uu/ptx/src/main.rs +++ b/src/uu/ptx/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_ptx); +uucore::bin!(uu_ptx); diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 41f55d2e6..c78aa07f4 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -674,7 +674,7 @@ mod options { pub static WIDTH: &str = "width"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/pwd/Cargo.toml b/src/uu/pwd/Cargo.toml index a6cccb0f1..bb47b9f2d 100644 --- a/src/uu/pwd/Cargo.toml +++ b/src/uu/pwd/Cargo.toml @@ -17,7 +17,6 @@ path = "src/pwd.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "pwd" diff --git a/src/uu/pwd/src/main.rs b/src/uu/pwd/src/main.rs index c5716d2c9..710a9b230 100644 --- a/src/uu/pwd/src/main.rs +++ b/src/uu/pwd/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_pwd); +uucore::bin!(uu_pwd); diff --git a/src/uu/pwd/src/pwd.rs b/src/uu/pwd/src/pwd.rs index e20f73af1..0fc9cbdd7 100644 --- a/src/uu/pwd/src/pwd.rs +++ b/src/uu/pwd/src/pwd.rs @@ -124,7 +124,7 @@ fn usage() -> String { format!("{0} [OPTION]... FILE...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/readlink/Cargo.toml b/src/uu/readlink/Cargo.toml index 35be61542..638d123b5 100644 --- a/src/uu/readlink/Cargo.toml +++ b/src/uu/readlink/Cargo.toml @@ -18,11 +18,7 @@ path = "src/readlink.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "readlink" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/readlink/src/main.rs b/src/uu/readlink/src/main.rs index 651fd73ca..57d5988f7 100644 --- a/src/uu/readlink/src/main.rs +++ b/src/uu/readlink/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_readlink); +uucore::bin!(uu_readlink); diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index e6dbc2fd0..826a97cec 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -34,7 +34,7 @@ fn usage() -> String { format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/realpath/Cargo.toml b/src/uu/realpath/Cargo.toml index 9c1919fb4..38996de69 100644 --- a/src/uu/realpath/Cargo.toml +++ b/src/uu/realpath/Cargo.toml @@ -17,11 +17,7 @@ path = "src/realpath.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "realpath" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/realpath/src/main.rs b/src/uu/realpath/src/main.rs index 8b8a8dc5e..0d7e188d1 100644 --- a/src/uu/realpath/src/main.rs +++ b/src/uu/realpath/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_realpath); +uucore::bin!(uu_realpath); diff --git a/src/uu/realpath/src/realpath.rs b/src/uu/realpath/src/realpath.rs index 7a65376e8..21fb974e3 100644 --- a/src/uu/realpath/src/realpath.rs +++ b/src/uu/realpath/src/realpath.rs @@ -37,7 +37,7 @@ fn usage() -> String { format!("{0} [OPTION]... FILE...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/relpath/Cargo.toml b/src/uu/relpath/Cargo.toml index 6c4894bca..d631fa66c 100644 --- a/src/uu/relpath/Cargo.toml +++ b/src/uu/relpath/Cargo.toml @@ -17,11 +17,7 @@ path = "src/relpath.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "relpath" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/relpath/src/main.rs b/src/uu/relpath/src/main.rs index 22aa68d53..b7dba76ce 100644 --- a/src/uu/relpath/src/main.rs +++ b/src/uu/relpath/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_relpath); +uucore::bin!(uu_relpath); diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index 2802fff37..20ecfd751 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -28,7 +28,7 @@ fn usage() -> String { format!("{} [-d DIR] TO [FROM]", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/rm/Cargo.toml b/src/uu/rm/Cargo.toml index 26dcc58fc..190294090 100644 --- a/src/uu/rm/Cargo.toml +++ b/src/uu/rm/Cargo.toml @@ -19,7 +19,6 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } walkdir = "2.2" remove_dir_all = "0.5.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(windows)'.dependencies] winapi = { version="0.3", features=[] } @@ -27,6 +26,3 @@ winapi = { version="0.3", features=[] } [[bin]] name = "rm" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/rm/src/main.rs b/src/uu/rm/src/main.rs index 960867359..966365137 100644 --- a/src/uu/rm/src/main.rs +++ b/src/uu/rm/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_rm); +uucore::bin!(uu_rm); diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 08810f483..cf2522b39 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -76,7 +76,7 @@ fn get_long_usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let long_usage = get_long_usage(); diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index bd58614dc..8dcb0cf97 100644 --- a/src/uu/rmdir/Cargo.toml +++ b/src/uu/rmdir/Cargo.toml @@ -17,7 +17,6 @@ path = "src/rmdir.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } libc = "0.2.42" [[bin]] diff --git a/src/uu/rmdir/src/main.rs b/src/uu/rmdir/src/main.rs index 92ff22c07..b10f0ade8 100644 --- a/src/uu/rmdir/src/main.rs +++ b/src/uu/rmdir/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_rmdir); +uucore::bin!(uu_rmdir); diff --git a/src/uu/rmdir/src/rmdir.rs b/src/uu/rmdir/src/rmdir.rs index 8b55ac7e0..d210ce105 100644 --- a/src/uu/rmdir/src/rmdir.rs +++ b/src/uu/rmdir/src/rmdir.rs @@ -29,7 +29,7 @@ fn usage() -> String { format!("{0} [OPTION]... DIRECTORY...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/runcon/Cargo.toml b/src/uu/runcon/Cargo.toml index 3c651bb66..7cdb4d9a3 100644 --- a/src/uu/runcon/Cargo.toml +++ b/src/uu/runcon/Cargo.toml @@ -16,7 +16,6 @@ path = "src/runcon.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version = ">=0.0.9", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] } -uucore_procs = { version = ">=0.0.6", package="uucore_procs", path="../../uucore_procs" } selinux = { version = "0.2" } fts-sys = { version = "0.2" } thiserror = { version = "1.0" } diff --git a/src/uu/runcon/src/main.rs b/src/uu/runcon/src/main.rs index 86aae54e5..1d3cef4cb 100644 --- a/src/uu/runcon/src/main.rs +++ b/src/uu/runcon/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_runcon); +uucore::bin!(uu_runcon); diff --git a/src/uu/runcon/src/runcon.rs b/src/uu/runcon/src/runcon.rs index 2e013db36..4b8e6e3bd 100644 --- a/src/uu/runcon/src/runcon.rs +++ b/src/uu/runcon/src/runcon.rs @@ -44,7 +44,7 @@ fn get_usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = get_usage(); diff --git a/src/uu/seq/Cargo.toml b/src/uu/seq/Cargo.toml index 669ba1c53..e6b5a2863 100644 --- a/src/uu/seq/Cargo.toml +++ b/src/uu/seq/Cargo.toml @@ -21,11 +21,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } num-bigint = "0.4.0" num-traits = "0.2.14" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["memo"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "seq" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/seq/src/main.rs b/src/uu/seq/src/main.rs index 266ac5d11..4b8a296b9 100644 --- a/src/uu/seq/src/main.rs +++ b/src/uu/seq/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_seq); +uucore::bin!(uu_seq); diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index d51cb938d..7f6043398 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -58,7 +58,7 @@ type RangeInt = (ExtendedBigInt, ExtendedBigInt, ExtendedBigInt); /// The elements are (first, increment, last). type RangeFloat = (ExtendedBigDecimal, ExtendedBigDecimal, ExtendedBigDecimal); -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/shred/Cargo.toml b/src/uu/shred/Cargo.toml index 46608dd86..857e371bb 100644 --- a/src/uu/shred/Cargo.toml +++ b/src/uu/shred/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" rand = "0.8" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "shred" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/shred/src/main.rs b/src/uu/shred/src/main.rs index ea7a42f65..c3525c15e 100644 --- a/src/uu/shred/src/main.rs +++ b/src/uu/shred/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_shred); +uucore::bin!(uu_shred); diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 7f951329c..d3a1c207b 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -267,7 +267,7 @@ pub mod options { pub const ZERO: &str = "zero"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/shuf/Cargo.toml b/src/uu/shuf/Cargo.toml index 722d9722b..03dd11abc 100644 --- a/src/uu/shuf/Cargo.toml +++ b/src/uu/shuf/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } rand = "0.8" rand_core = "0.6" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "shuf" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/shuf/src/main.rs b/src/uu/shuf/src/main.rs index fc6e2b4ae..8214db209 100644 --- a/src/uu/shuf/src/main.rs +++ b/src/uu/shuf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_shuf); +uucore::bin!(uu_shuf); diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index 0c3c66faf..a7dcd48e9 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -52,7 +52,7 @@ mod options { pub static FILE: &str = "file"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/sleep/Cargo.toml b/src/uu/sleep/Cargo.toml index 3c9167e51..37066f3cf 100644 --- a/src/uu/sleep/Cargo.toml +++ b/src/uu/sleep/Cargo.toml @@ -17,7 +17,6 @@ path = "src/sleep.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "sleep" diff --git a/src/uu/sleep/src/main.rs b/src/uu/sleep/src/main.rs index 16c3100aa..536edbb23 100644 --- a/src/uu/sleep/src/main.rs +++ b/src/uu/sleep/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sleep); +uucore::bin!(uu_sleep); diff --git a/src/uu/sleep/src/sleep.rs b/src/uu/sleep/src/sleep.rs index 75306318d..fccb4be46 100644 --- a/src/uu/sleep/src/sleep.rs +++ b/src/uu/sleep/src/sleep.rs @@ -31,7 +31,7 @@ fn usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml index 3d827193d..1a99e0445 100644 --- a/src/uu/sort/Cargo.toml +++ b/src/uu/sort/Cargo.toml @@ -28,7 +28,6 @@ rayon = "1.5" tempfile = "3" unicode-width = "0.1.8" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "sort" diff --git a/src/uu/sort/src/main.rs b/src/uu/sort/src/main.rs index ab463776d..f552ce37e 100644 --- a/src/uu/sort/src/main.rs +++ b/src/uu/sort/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sort); +uucore::bin!(uu_sort); diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 0ed13e978..faafbba1c 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -1056,7 +1056,7 @@ fn make_sort_mode_arg<'a>(mode: &'a str, short: char, help: &'a str) -> Arg<'a> arg } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/split/Cargo.toml b/src/uu/split/Cargo.toml index 447e28f6a..cf2e76747 100644 --- a/src/uu/split/Cargo.toml +++ b/src/uu/split/Cargo.toml @@ -17,11 +17,7 @@ path = "src/split.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "split" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/split/src/filenames.rs b/src/uu/split/src/filenames.rs index da72e090e..36488e7e4 100644 --- a/src/uu/split/src/filenames.rs +++ b/src/uu/split/src/filenames.rs @@ -355,23 +355,23 @@ fn num_prefix(i: usize) -> String { /// assert_eq!(factory.make(650).unwrap(), "zaaa"); /// assert_eq!(factory.make(6551).unwrap(), "zaab"); /// ``` -pub struct FilenameFactory { - additional_suffix: String, - prefix: String, +pub struct FilenameFactory<'a> { + prefix: &'a str, + additional_suffix: &'a str, suffix_length: usize, use_numeric_suffix: bool, } -impl FilenameFactory { +impl<'a> FilenameFactory<'a> { /// Create a new instance of this struct. /// /// For an explanation of the parameters, see the struct documentation. pub fn new( - prefix: String, - additional_suffix: String, + prefix: &'a str, + additional_suffix: &'a str, suffix_length: usize, use_numeric_suffix: bool, - ) -> FilenameFactory { + ) -> FilenameFactory<'a> { FilenameFactory { prefix, additional_suffix, @@ -392,8 +392,8 @@ impl FilenameFactory { /// ```rust,ignore /// use crate::filenames::FilenameFactory; /// - /// let prefix = String::new(); - /// let suffix = String::new(); + /// let prefix = ""; + /// let suffix = ""; /// let width = 1; /// let use_numeric_suffix = true; /// let factory = FilenameFactory::new(prefix, suffix, width, use_numeric_suffix); @@ -401,15 +401,16 @@ impl FilenameFactory { /// assert_eq!(factory.make(10), None); /// ``` pub fn make(&self, i: usize) -> Option { - let prefix = self.prefix.clone(); - let suffix1 = match (self.use_numeric_suffix, self.suffix_length) { + let suffix = match (self.use_numeric_suffix, self.suffix_length) { (true, 0) => Some(num_prefix(i)), (false, 0) => str_prefix(i), (true, width) => num_prefix_fixed_width(i, width), (false, width) => str_prefix_fixed_width(i, width), }?; - let suffix2 = &self.additional_suffix; - Some(prefix + &suffix1 + suffix2) + Some(format!( + "{}{}{}", + self.prefix, suffix, self.additional_suffix + )) } } @@ -513,7 +514,7 @@ mod tests { #[test] fn test_alphabetic_suffix() { - let factory = FilenameFactory::new("123".to_string(), "789".to_string(), 3, false); + let factory = FilenameFactory::new("123", "789", 3, false); assert_eq!(factory.make(0).unwrap(), "123aaa789"); assert_eq!(factory.make(1).unwrap(), "123aab789"); assert_eq!(factory.make(28).unwrap(), "123abc789"); @@ -521,7 +522,7 @@ mod tests { #[test] fn test_numeric_suffix() { - let factory = FilenameFactory::new("abc".to_string(), "xyz".to_string(), 3, true); + let factory = FilenameFactory::new("abc", "xyz", 3, true); assert_eq!(factory.make(0).unwrap(), "abc000xyz"); assert_eq!(factory.make(1).unwrap(), "abc001xyz"); assert_eq!(factory.make(123).unwrap(), "abc123xyz"); diff --git a/src/uu/split/src/main.rs b/src/uu/split/src/main.rs index 87f15f529..0ef3e026f 100644 --- a/src/uu/split/src/main.rs +++ b/src/uu/split/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_split); +uucore::bin!(uu_split); diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 7fa4af30e..dbc17da70 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -14,8 +14,7 @@ use crate::filenames::FilenameFactory; use clap::{crate_version, App, AppSettings, Arg, ArgMatches}; use std::convert::TryFrom; use std::env; -use std::fs::remove_file; -use std::fs::File; +use std::fs::{metadata, remove_file, File}; use std::io::{stdin, BufRead, BufReader, BufWriter, Read, Write}; use std::path::Path; use uucore::display::Quotable; @@ -27,6 +26,7 @@ static OPT_LINE_BYTES: &str = "line-bytes"; static OPT_LINES: &str = "lines"; static OPT_ADDITIONAL_SUFFIX: &str = "additional-suffix"; static OPT_FILTER: &str = "filter"; +static OPT_NUMBER: &str = "number"; static OPT_NUMERIC_SUFFIXES: &str = "numeric-suffixes"; static OPT_SUFFIX_LENGTH: &str = "suffix-length"; static OPT_DEFAULT_SUFFIX_LENGTH: &str = "0"; @@ -53,53 +53,15 @@ size is 1000, and default PREFIX is 'x'. With no INPUT, or when INPUT is ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let long_usage = get_long_usage(); - let matches = uu_app() .override_usage(&usage[..]) .after_help(&long_usage[..]) .get_matches_from(args); - - let mut settings = Settings { - prefix: "".to_owned(), - numeric_suffix: false, - suffix_length: 0, - additional_suffix: "".to_owned(), - input: "".to_owned(), - filter: None, - strategy: Strategy::Lines(1000), - verbose: false, - }; - - settings.suffix_length = matches - .value_of(OPT_SUFFIX_LENGTH) - .unwrap() - .parse() - .unwrap_or_else(|_| panic!("Invalid number for {}", OPT_SUFFIX_LENGTH)); - - settings.numeric_suffix = matches.occurrences_of(OPT_NUMERIC_SUFFIXES) > 0; - settings.additional_suffix = matches.value_of(OPT_ADDITIONAL_SUFFIX).unwrap().to_owned(); - - settings.verbose = matches.occurrences_of("verbose") > 0; - settings.strategy = Strategy::from(&matches)?; - settings.input = matches.value_of(ARG_INPUT).unwrap().to_owned(); - settings.prefix = matches.value_of(ARG_PREFIX).unwrap().to_owned(); - - if matches.occurrences_of(OPT_FILTER) > 0 { - if cfg!(windows) { - // see https://github.com/rust-lang/rust/issues/29494 - return Err(USimpleError::new( - -1, - format!("{} is currently not supported in this platform", OPT_FILTER), - )); - } else { - settings.filter = Some(matches.value_of(OPT_FILTER).unwrap().to_owned()); - } - } - + let settings = Settings::from(matches)?; split(settings) } @@ -132,6 +94,13 @@ pub fn uu_app<'a>() -> App<'a> { .default_value("1000") .help("put NUMBER lines/records per output file"), ) + .arg( + Arg::new(OPT_NUMBER) + .short('n') + .long(OPT_NUMBER) + .takes_value(true) + .help("generate CHUNKS output files; see explanation below"), + ) // rest of the arguments .arg( Arg::new(OPT_ADDITIONAL_SUFFIX) @@ -194,6 +163,9 @@ enum Strategy { /// Each chunk has as many lines as possible without exceeding the /// specified number of bytes. LineBytes(usize), + + /// Split the file into this many chunks. + Number(usize), } impl Strategy { @@ -208,31 +180,43 @@ impl Strategy { matches.occurrences_of(OPT_LINES), matches.occurrences_of(OPT_BYTES), matches.occurrences_of(OPT_LINE_BYTES), + matches.occurrences_of(OPT_NUMBER), ) { - (0, 0, 0) => Ok(Strategy::Lines(1000)), - (1, 0, 0) => { + (0, 0, 0, 0) => Ok(Strategy::Lines(1000)), + (1, 0, 0, 0) => { let s = matches.value_of(OPT_LINES).unwrap(); let n = parse_size(s) .map_err(|e| USimpleError::new(1, format!("invalid number of lines: {}", e)))?; Ok(Strategy::Lines(n)) } - (0, 1, 0) => { + (0, 1, 0, 0) => { let s = matches.value_of(OPT_BYTES).unwrap(); let n = parse_size(s) .map_err(|e| USimpleError::new(1, format!("invalid number of bytes: {}", e)))?; Ok(Strategy::Bytes(n)) } - (0, 0, 1) => { + (0, 0, 1, 0) => { let s = matches.value_of(OPT_LINE_BYTES).unwrap(); let n = parse_size(s) .map_err(|e| USimpleError::new(1, format!("invalid number of bytes: {}", e)))?; Ok(Strategy::LineBytes(n)) } + (0, 0, 0, 1) => { + let s = matches.value_of(OPT_NUMBER).unwrap(); + let n = s.parse::().map_err(|e| { + USimpleError::new(1, format!("invalid number of chunks: {}", e)) + })?; + Ok(Strategy::Number(n)) + } _ => Err(UUsageError::new(1, "cannot split in more than one way")), } } } +/// Parameters that control how a file gets split. +/// +/// You can convert an [`ArgMatches`] instance into a [`Settings`] +/// instance by calling [`Settings::from`]. struct Settings { prefix: String, numeric_suffix: bool, @@ -245,6 +229,36 @@ struct Settings { verbose: bool, } +impl Settings { + /// Parse a strategy from the command-line arguments. + fn from(matches: ArgMatches) -> UResult { + let result = Settings { + suffix_length: matches + .value_of(OPT_SUFFIX_LENGTH) + .unwrap() + .parse() + .unwrap_or_else(|_| panic!("Invalid number for {}", OPT_SUFFIX_LENGTH)), + numeric_suffix: matches.occurrences_of(OPT_NUMERIC_SUFFIXES) > 0, + additional_suffix: matches.value_of(OPT_ADDITIONAL_SUFFIX).unwrap().to_owned(), + verbose: matches.occurrences_of("verbose") > 0, + strategy: Strategy::from(&matches)?, + input: matches.value_of(ARG_INPUT).unwrap().to_owned(), + prefix: matches.value_of(ARG_PREFIX).unwrap().to_owned(), + filter: matches.value_of(OPT_FILTER).map(|s| s.to_owned()), + }; + #[cfg(windows)] + if result.filter.is_some() { + // see https://github.com/rust-lang/rust/issues/29494 + return Err(USimpleError::new( + -1, + format!("{} is currently not supported in this platform", OPT_FILTER), + )); + } + + Ok(result) + } +} + trait Splitter { // Consume as much as possible from `reader` so as to saturate `writer`. // Equivalent to finishing one of the part files. Returns the number of @@ -344,6 +358,84 @@ impl Splitter for ByteSplitter { } } +/// Split a file into a specific number of chunks by byte. +/// +/// This function always creates one output file for each chunk, even +/// if there is an error reading or writing one of the chunks or if +/// the input file is truncated. However, if the `filter` option is +/// being used, then no files are created. +/// +/// # Errors +/// +/// This function returns an error if there is a problem reading from +/// `reader` or writing to one of the output files. +fn split_into_n_chunks_by_byte( + settings: &Settings, + reader: &mut R, + num_chunks: usize, +) -> UResult<()> +where + R: Read, +{ + // Get the size of the input file in bytes and compute the number + // of bytes per chunk. + let metadata = metadata(&settings.input).unwrap(); + let num_bytes = metadata.len(); + let chunk_size = (num_bytes / (num_chunks as u64)) as usize; + + // This object is responsible for creating the filename for each chunk. + let filename_factory = FilenameFactory::new( + &settings.prefix, + &settings.additional_suffix, + settings.suffix_length, + settings.numeric_suffix, + ); + + // Create one writer for each chunk. This will create each + // of the underlying files (if not in `--filter` mode). + let mut writers = vec![]; + for i in 0..num_chunks { + let filename = filename_factory + .make(i) + .ok_or_else(|| USimpleError::new(1, "output file suffixes exhausted"))?; + let writer = platform::instantiate_current_writer(&settings.filter, filename.as_str()); + writers.push(writer); + } + + // This block evaluates to an object of type `std::io::Result<()>`. + { + // Write `chunk_size` bytes from the reader into each writer + // except the last. + // + // Re-use the buffer to avoid re-allocating a `Vec` on each + // iteration. The contents will be completely overwritten each + // time we call `read_exact()`. + // + // The last writer gets all remaining bytes so that if the number + // of bytes in the input file was not evenly divisible by + // `num_chunks`, we don't leave any bytes behind. + let mut buf = vec![0u8; chunk_size]; + for writer in writers.iter_mut().take(num_chunks - 1) { + reader.read_exact(&mut buf)?; + writer.write_all(&buf)?; + } + + // Write all the remaining bytes to the last chunk. + // + // To do this, we resize our buffer to have the necessary number + // of bytes. + let i = num_chunks - 1; + let last_chunk_size = num_bytes as usize - (chunk_size * (num_chunks - 1)); + buf.resize(last_chunk_size, 0); + + reader.read_exact(&mut buf)?; + writers[i].write_all(&buf)?; + + Ok(()) + } + .map_err_context(|| "I/O error".to_string()) +} + fn split(settings: Settings) -> UResult<()> { let mut reader = BufReader::new(if settings.input == "-" { Box::new(stdin()) as Box @@ -357,17 +449,22 @@ fn split(settings: Settings) -> UResult<()> { Box::new(r) as Box }); + if let Strategy::Number(num_chunks) = settings.strategy { + return split_into_n_chunks_by_byte(&settings, &mut reader, num_chunks); + } + let mut splitter: Box = match settings.strategy { Strategy::Lines(chunk_size) => Box::new(LineSplitter::new(chunk_size)), Strategy::Bytes(chunk_size) | Strategy::LineBytes(chunk_size) => { Box::new(ByteSplitter::new(chunk_size)) } + _ => unreachable!(), }; // This object is responsible for creating the filename for each chunk. let filename_factory = FilenameFactory::new( - settings.prefix, - settings.additional_suffix, + &settings.prefix, + &settings.additional_suffix, settings.suffix_length, settings.numeric_suffix, ); diff --git a/src/uu/stat/Cargo.toml b/src/uu/stat/Cargo.toml index 08735d426..e0ed8aa73 100644 --- a/src/uu/stat/Cargo.toml +++ b/src/uu/stat/Cargo.toml @@ -17,11 +17,7 @@ path = "src/stat.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "libc", "fs", "fsext"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "stat" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/stat/src/main.rs b/src/uu/stat/src/main.rs index 839eff7de..3607ac4ae 100644 --- a/src/uu/stat/src/main.rs +++ b/src/uu/stat/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_stat); +uucore::bin!(uu_stat); diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index b3392f13c..933b26ef9 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -947,7 +947,7 @@ for details about the options it supports. ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let long_usage = get_long_usage(); diff --git a/src/uu/stdbuf/Cargo.toml b/src/uu/stdbuf/Cargo.toml index 919ce99fa..a65d77c76 100644 --- a/src/uu/stdbuf/Cargo.toml +++ b/src/uu/stdbuf/Cargo.toml @@ -18,7 +18,6 @@ path = "src/stdbuf.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } tempfile = "3.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [build-dependencies] libstdbuf = { version="0.0.12", package="uu_stdbuf_libstdbuf", path="src/libstdbuf" } diff --git a/src/uu/stdbuf/src/libstdbuf/Cargo.toml b/src/uu/stdbuf/src/libstdbuf/Cargo.toml index 4e35a9438..5c8a80f0e 100644 --- a/src/uu/stdbuf/src/libstdbuf/Cargo.toml +++ b/src/uu/stdbuf/src/libstdbuf/Cargo.toml @@ -20,7 +20,6 @@ crate-type = ["cdylib", "rlib"] # XXX: note: the rlib is just to prevent Cargo f cpp = "0.5" libc = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../../../uucore_procs" } [build-dependencies] cpp_build = "0.4" diff --git a/src/uu/stdbuf/src/main.rs b/src/uu/stdbuf/src/main.rs index 1989a3b8d..cf6a2408a 100644 --- a/src/uu/stdbuf/src/main.rs +++ b/src/uu/stdbuf/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_stdbuf); +uucore::bin!(uu_stdbuf); diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 51163128b..cc5da742e 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -149,7 +149,7 @@ fn get_preload_env(tmp_dir: &mut TempDir) -> io::Result<(String, PathBuf)> { Ok((preload.to_owned(), inject_path)) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/sum/Cargo.toml b/src/uu/sum/Cargo.toml index d8d077740..7bc4468d0 100644 --- a/src/uu/sum/Cargo.toml +++ b/src/uu/sum/Cargo.toml @@ -17,11 +17,7 @@ path = "src/sum.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "sum" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/sum/src/main.rs b/src/uu/sum/src/main.rs index 85f4d0079..9d3c72e6f 100644 --- a/src/uu/sum/src/main.rs +++ b/src/uu/sum/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sum); +uucore::bin!(uu_sum); diff --git a/src/uu/sum/src/sum.rs b/src/uu/sum/src/sum.rs index 4d13b189d..2f7052fa9 100644 --- a/src/uu/sum/src/sum.rs +++ b/src/uu/sum/src/sum.rs @@ -96,7 +96,7 @@ mod options { pub static SYSTEM_V_COMPATIBLE: &str = "sysv"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index e61000029..364ab181b 100644 --- a/src/uu/sync/Cargo.toml +++ b/src/uu/sync/Cargo.toml @@ -18,7 +18,6 @@ path = "src/sync.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] } [[bin]] diff --git a/src/uu/sync/src/main.rs b/src/uu/sync/src/main.rs index 9786fc371..54747b050 100644 --- a/src/uu/sync/src/main.rs +++ b/src/uu/sync/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_sync); +uucore::bin!(uu_sync); diff --git a/src/uu/sync/src/sync.rs b/src/uu/sync/src/sync.rs index e812fdf5a..253453bfd 100644 --- a/src/uu/sync/src/sync.rs +++ b/src/uu/sync/src/sync.rs @@ -161,7 +161,7 @@ fn usage() -> String { format!("{0} [OPTION]... FILE...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/tac/Cargo.toml b/src/uu/tac/Cargo.toml index c23f4976d..1c5242ba7 100644 --- a/src/uu/tac/Cargo.toml +++ b/src/uu/tac/Cargo.toml @@ -22,11 +22,7 @@ memmap2 = "0.5" regex = "1" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "tac" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/tac/src/main.rs b/src/uu/tac/src/main.rs index 018821c73..7e1437732 100644 --- a/src/uu/tac/src/main.rs +++ b/src/uu/tac/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tac); +uucore::bin!(uu_tac); diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index 84353a039..c729f1581 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -35,7 +35,7 @@ mod options { pub static FILE: &str = "file"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index ab9d8647a..d70502dab 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -18,7 +18,6 @@ path = "src/tail.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(windows)'.dependencies] winapi = { version="0.3", features=["fileapi", "handleapi", "processthreadsapi", "synchapi", "winbase"] } @@ -32,6 +31,3 @@ nix = "0.23.1" [[bin]] name = "tail" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/tail/src/lines.rs b/src/uu/tail/src/lines.rs index 6e472b32e..ee8b36662 100644 --- a/src/uu/tail/src/lines.rs +++ b/src/uu/tail/src/lines.rs @@ -17,31 +17,45 @@ use std::io::BufRead; /// /// This function is just like [`BufRead::lines`], but it includes the /// line ending characters in each yielded [`String`] if the input -/// data has them. +/// data has them. Set the `sep` parameter to the line ending +/// character; for Unix line endings, use `b'\n'`. /// /// # Examples /// +/// Use `sep` to specify an alternate character for line endings. For +/// example, if lines are terminated by the null character `b'\0'`: +/// +/// ```rust,ignore +/// use std::io::BufRead; +/// use std::io::Cursor; +/// +/// let cursor = Cursor::new(b"x\0y\0z\0"); +/// let mut it = lines(cursor, b'\0').map(|l| l.unwrap()); +/// +/// assert_eq!(it.next(), Some(Vec::from("x\0"))); +/// assert_eq!(it.next(), Some(Vec::from("y\0"))); +/// assert_eq!(it.next(), Some(Vec::from("z\0"))); +/// assert_eq!(it.next(), None); +/// ``` +/// /// If the input data does not end with a newline character (`'\n'`), /// then the last [`String`] yielded by this iterator also does not /// end with a newline: /// /// ```rust,ignore -/// use std::io::BufRead; -/// use std::io::Cursor; -/// /// let cursor = Cursor::new(b"x\ny\nz"); -/// let mut it = cursor.lines(); +/// let mut it = lines(cursor, b'\n').map(|l| l.unwrap()); /// -/// assert_eq!(it.next(), Some(String::from("x\n"))); -/// assert_eq!(it.next(), Some(String::from("y\n"))); -/// assert_eq!(it.next(), Some(String::from("z"))); +/// assert_eq!(it.next(), Some(Vec::from("x\n"))); +/// assert_eq!(it.next(), Some(Vec::from("y\n"))); +/// assert_eq!(it.next(), Some(Vec::from("z"))); /// assert_eq!(it.next(), None); /// ``` -pub(crate) fn lines(reader: B) -> Lines +pub(crate) fn lines(reader: B, sep: u8) -> Lines where B: BufRead, { - Lines { buf: reader } + Lines { buf: reader, sep } } /// An iterator over the lines of an instance of `BufRead`. @@ -50,14 +64,15 @@ where /// Please see the documentation of [`lines`] for more details. pub(crate) struct Lines { buf: B, + sep: u8, } impl Iterator for Lines { - type Item = std::io::Result; + type Item = std::io::Result>; - fn next(&mut self) -> Option> { - let mut buf = String::new(); - match self.buf.read_line(&mut buf) { + fn next(&mut self) -> Option>> { + let mut buf = Vec::new(); + match self.buf.read_until(self.sep, &mut buf) { Ok(0) => None, Ok(_n) => Some(Ok(buf)), Err(e) => Some(Err(e)), @@ -73,11 +88,24 @@ mod tests { #[test] fn test_lines() { let cursor = Cursor::new(b"x\ny\nz"); - let mut it = lines(cursor).map(|l| l.unwrap()); + let mut it = lines(cursor, b'\n').map(|l| l.unwrap()); - assert_eq!(it.next(), Some(String::from("x\n"))); - assert_eq!(it.next(), Some(String::from("y\n"))); - assert_eq!(it.next(), Some(String::from("z"))); + assert_eq!(it.next(), Some(Vec::from("x\n"))); + assert_eq!(it.next(), Some(Vec::from("y\n"))); + assert_eq!(it.next(), Some(Vec::from("z"))); + assert_eq!(it.next(), None); + } + + #[test] + fn test_lines_zero_terminated() { + use std::io::Cursor; + + let cursor = Cursor::new(b"x\0y\0z\0"); + let mut it = lines(cursor, b'\0').map(|l| l.unwrap()); + + assert_eq!(it.next(), Some(Vec::from("x\0"))); + assert_eq!(it.next(), Some(Vec::from("y\0"))); + assert_eq!(it.next(), Some(Vec::from("z\0"))); assert_eq!(it.next(), None); } } diff --git a/src/uu/tail/src/main.rs b/src/uu/tail/src/main.rs index dd89ce2c7..6bd55d279 100644 --- a/src/uu/tail/src/main.rs +++ b/src/uu/tail/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tail); +uucore::bin!(uu_tail); diff --git a/src/uu/tail/src/tail.rs b/src/uu/tail/src/tail.rs index f745574e4..7c2652a7b 100644 --- a/src/uu/tail/src/tail.rs +++ b/src/uu/tail/src/tail.rs @@ -158,7 +158,7 @@ impl Settings { } #[allow(clippy::cognitive_complexity)] -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = match Settings::get_from(args) { Ok(o) => o, @@ -575,9 +575,12 @@ fn unbounded_tail(reader: &mut BufReader, settings: &Settings) -> UR // contains count lines/chars. When reaching the end of file, output the // data in the ringbuf. match settings.mode { - FilterMode::Lines(count, _) => { - for line in unbounded_tail_collect(lines(reader), count, settings.beginning) { - print!("{}", line); + FilterMode::Lines(count, sep) => { + let mut stdout = stdout(); + for line in unbounded_tail_collect(lines(reader, sep), count, settings.beginning) { + stdout + .write_all(&line) + .map_err_context(|| String::from("IO error"))?; } } FilterMode::Bytes(count) => { diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index 5e99cfc95..054e3592e 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" retain_mut = "=0.1.2" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0 uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "tee" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/tee/src/main.rs b/src/uu/tee/src/main.rs index 2b483d9d8..59bb3184b 100644 --- a/src/uu/tee/src/main.rs +++ b/src/uu/tee/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tee); +uucore::bin!(uu_tee); diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index a96d44454..fb102ab2a 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -38,7 +38,7 @@ fn usage() -> String { format!("{0} [OPTION]... [FILE]...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index e8b3b7073..0acad31ab 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -18,7 +18,6 @@ path = "src/test.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(target_os = "redox")'.dependencies] redox_syscall = "0.2" @@ -26,6 +25,3 @@ redox_syscall = "0.2" [[bin]] name = "test" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/test/src/main.rs b/src/uu/test/src/main.rs index 9f4e6985f..58f20bea4 100644 --- a/src/uu/test/src/main.rs +++ b/src/uu/test/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_test); +uucore::bin!(uu_test); diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index c2bd9d3d8..566deb732 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -92,7 +92,7 @@ pub fn uu_app<'a>() -> App<'a> { .setting(AppSettings::DisableVersionFlag) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(mut args: impl uucore::Args) -> UResult<()> { let program = args.next().unwrap_or_else(|| OsString::from("test")); let binary_name = uucore::util_name(); diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index 43ec3a6cb..ae0cb1a0b 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -19,12 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" nix = "0.23.1" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["process", "signals"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } - [[bin]] name = "timeout" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/timeout/src/main.rs b/src/uu/timeout/src/main.rs index 2479f91c1..e7d3224ff 100644 --- a/src/uu/timeout/src/main.rs +++ b/src/uu/timeout/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_timeout); +uucore::bin!(uu_timeout); diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index f0d2325a5..2542bd6e6 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -100,7 +100,7 @@ impl Config { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index 87bbea5f5..dd024eacd 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -19,7 +19,6 @@ filetime = "0.2.1" clap = { version = "3.0", features = ["wrap_help", "cargo"] } time = "0.1.40" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "touch" diff --git a/src/uu/touch/src/main.rs b/src/uu/touch/src/main.rs index e8a2729a2..33b77a241 100644 --- a/src/uu/touch/src/main.rs +++ b/src/uu/touch/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_touch); +uucore::bin!(uu_touch); diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index ba8d899e9..b1df1aca4 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -52,7 +52,7 @@ fn usage() -> String { format!("{0} [OPTION]... [USER]", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/tr/Cargo.toml b/src/uu/tr/Cargo.toml index 62e4d3e30..bfccfb4e7 100644 --- a/src/uu/tr/Cargo.toml +++ b/src/uu/tr/Cargo.toml @@ -18,11 +18,7 @@ path = "src/tr.rs" nom = "7.1.0" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "tr" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/tr/src/main.rs b/src/uu/tr/src/main.rs index 9118c3628..7365a22ad 100644 --- a/src/uu/tr/src/main.rs +++ b/src/uu/tr/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tr); +uucore::bin!(uu_tr); diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index e5fa4bcd5..26c8d6d82 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -41,7 +41,7 @@ fn get_long_usage() -> String { .to_string() } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/true/Cargo.toml b/src/uu/true/Cargo.toml index 8237b0ef8..82023585f 100644 --- a/src/uu/true/Cargo.toml +++ b/src/uu/true/Cargo.toml @@ -17,7 +17,6 @@ path = "src/true.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "true" diff --git a/src/uu/true/src/main.rs b/src/uu/true/src/main.rs index b30f4d4cb..700bece65 100644 --- a/src/uu/true/src/main.rs +++ b/src/uu/true/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_true); +uucore::bin!(uu_true); diff --git a/src/uu/true/src/true.rs b/src/uu/true/src/true.rs index 249bc4e4f..ff5b08e85 100644 --- a/src/uu/true/src/true.rs +++ b/src/uu/true/src/true.rs @@ -8,7 +8,7 @@ use clap::{App, AppSettings}; use uucore::error::UResult; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { uu_app().get_matches_from(args); Ok(()) diff --git a/src/uu/truncate/Cargo.toml b/src/uu/truncate/Cargo.toml index af261beed..402c201f6 100644 --- a/src/uu/truncate/Cargo.toml +++ b/src/uu/truncate/Cargo.toml @@ -17,11 +17,7 @@ path = "src/truncate.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "truncate" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/truncate/src/main.rs b/src/uu/truncate/src/main.rs index 46e65faea..6900db57d 100644 --- a/src/uu/truncate/src/main.rs +++ b/src/uu/truncate/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_truncate); +uucore::bin!(uu_truncate); diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 5be63736b..fb945a00c 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -107,7 +107,7 @@ fn get_long_usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let long_usage = get_long_usage(); diff --git a/src/uu/tsort/Cargo.toml b/src/uu/tsort/Cargo.toml index 6211ee0af..8964486bf 100644 --- a/src/uu/tsort/Cargo.toml +++ b/src/uu/tsort/Cargo.toml @@ -17,11 +17,7 @@ path = "src/tsort.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "tsort" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/tsort/src/main.rs b/src/uu/tsort/src/main.rs index 0694678d4..480d14ffd 100644 --- a/src/uu/tsort/src/main.rs +++ b/src/uu/tsort/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tsort); +uucore::bin!(uu_tsort); diff --git a/src/uu/tsort/src/tsort.rs b/src/uu/tsort/src/tsort.rs index b92c8ba44..c50b695ac 100644 --- a/src/uu/tsort/src/tsort.rs +++ b/src/uu/tsort/src/tsort.rs @@ -23,7 +23,7 @@ mod options { pub const FILE: &str = "file"; } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::ConvertLossy) diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index 486950831..bdb7ebe9c 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } libc = "0.2.42" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "tty" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/tty/src/main.rs b/src/uu/tty/src/main.rs index 01a01e5ca..4b708cd95 100644 --- a/src/uu/tty/src/main.rs +++ b/src/uu/tty/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_tty); +uucore::bin!(uu_tty); diff --git a/src/uu/tty/src/tty.rs b/src/uu/tty/src/tty.rs index 56008df74..69d62cf74 100644 --- a/src/uu/tty/src/tty.rs +++ b/src/uu/tty/src/tty.rs @@ -25,7 +25,7 @@ fn usage() -> String { format!("{0} [OPTION]...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let args = args diff --git a/src/uu/uname/Cargo.toml b/src/uu/uname/Cargo.toml index e1249ee60..b840b7584 100644 --- a/src/uu/uname/Cargo.toml +++ b/src/uu/uname/Cargo.toml @@ -18,11 +18,7 @@ path = "src/uname.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } platform-info = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "uname" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/uname/src/main.rs b/src/uu/uname/src/main.rs index 5252f4716..98640b395 100644 --- a/src/uu/uname/src/main.rs +++ b/src/uu/uname/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uname); +uucore::bin!(uu_uname); diff --git a/src/uu/uname/src/uname.rs b/src/uu/uname/src/uname.rs index 5ebf53c56..d007da1a0 100644 --- a/src/uu/uname/src/uname.rs +++ b/src/uu/uname/src/uname.rs @@ -47,7 +47,7 @@ const HOST_OS: &str = "Fuchsia"; #[cfg(target_os = "redox")] const HOST_OS: &str = "Redox"; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = format!("{} [OPTION]...", uucore::execution_phrase()); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/unexpand/Cargo.toml b/src/uu/unexpand/Cargo.toml index 37503d216..b679d786e 100644 --- a/src/uu/unexpand/Cargo.toml +++ b/src/uu/unexpand/Cargo.toml @@ -18,11 +18,7 @@ path = "src/unexpand.rs" clap = { version = "3.0", features = ["wrap_help", "cargo"] } unicode-width = "0.1.5" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "unexpand" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/unexpand/src/main.rs b/src/uu/unexpand/src/main.rs index 2e7b1d967..d7c90ba7e 100644 --- a/src/uu/unexpand/src/main.rs +++ b/src/uu/unexpand/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_unexpand); +uucore::bin!(uu_unexpand); diff --git a/src/uu/unexpand/src/unexpand.rs b/src/uu/unexpand/src/unexpand.rs index 6d030a4ea..aeac7cfe1 100644 --- a/src/uu/unexpand/src/unexpand.rs +++ b/src/uu/unexpand/src/unexpand.rs @@ -91,7 +91,7 @@ impl Options { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/uniq/Cargo.toml b/src/uu/uniq/Cargo.toml index eba1bb3c7..69d80a2fc 100644 --- a/src/uu/uniq/Cargo.toml +++ b/src/uu/uniq/Cargo.toml @@ -19,11 +19,7 @@ clap = { version = "3.0", features = ["wrap_help", "cargo"] } strum = "0.21" strum_macros = "0.21" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "uniq" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/uniq/src/main.rs b/src/uu/uniq/src/main.rs index 361c39f14..b6e6251cd 100644 --- a/src/uu/uniq/src/main.rs +++ b/src/uu/uniq/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uniq); +uucore::bin!(uu_uniq); diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index 991af05e8..c5192d98a 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -255,7 +255,7 @@ fn get_long_usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let long_usage = get_long_usage(); diff --git a/src/uu/unlink/Cargo.toml b/src/uu/unlink/Cargo.toml index 6d69bac97..0869427e9 100644 --- a/src/uu/unlink/Cargo.toml +++ b/src/uu/unlink/Cargo.toml @@ -17,7 +17,6 @@ path = "src/unlink.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "unlink" diff --git a/src/uu/unlink/src/main.rs b/src/uu/unlink/src/main.rs index b03d4a675..8e107866e 100644 --- a/src/uu/unlink/src/main.rs +++ b/src/uu/unlink/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_unlink); +uucore::bin!(uu_unlink); diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 2abc186b4..65544612b 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -18,7 +18,7 @@ use uucore::error::{FromIo, UResult}; static ABOUT: &str = "Unlink the file at FILE."; static OPT_PATH: &str = "FILE"; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().get_matches_from(args); diff --git a/src/uu/uptime/Cargo.toml b/src/uu/uptime/Cargo.toml index 81ed71356..fcce5bb47 100644 --- a/src/uu/uptime/Cargo.toml +++ b/src/uu/uptime/Cargo.toml @@ -18,7 +18,6 @@ path = "src/uptime.rs" chrono = "^0.4.11" clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc", "utmpx"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "uptime" diff --git a/src/uu/uptime/src/main.rs b/src/uu/uptime/src/main.rs index be5d5ab01..960886b86 100644 --- a/src/uu/uptime/src/main.rs +++ b/src/uu/uptime/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_uptime); +uucore::bin!(uu_uptime); diff --git a/src/uu/uptime/src/uptime.rs b/src/uu/uptime/src/uptime.rs index 2038098e9..a9d971e5b 100644 --- a/src/uu/uptime/src/uptime.rs +++ b/src/uu/uptime/src/uptime.rs @@ -36,7 +36,7 @@ fn usage() -> String { format!("{0} [OPTION]...", uucore::execution_phrase()) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); diff --git a/src/uu/users/Cargo.toml b/src/uu/users/Cargo.toml index f92214ff3..5125bcc33 100644 --- a/src/uu/users/Cargo.toml +++ b/src/uu/users/Cargo.toml @@ -17,7 +17,6 @@ path = "src/users.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "users" diff --git a/src/uu/users/src/main.rs b/src/uu/users/src/main.rs index f30a01ecb..eab36c2e3 100644 --- a/src/uu/users/src/main.rs +++ b/src/uu/users/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_users); +uucore::bin!(uu_users); diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index 726bcff4c..d545f84f1 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -30,7 +30,7 @@ If FILE is not specified, use {}. /var/log/wtmp as FILE is common.", ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); let after_help = get_long_usage(); diff --git a/src/uu/wc/Cargo.toml b/src/uu/wc/Cargo.toml index 4617f0d55..28520f1d7 100644 --- a/src/uu/wc/Cargo.toml +++ b/src/uu/wc/Cargo.toml @@ -17,7 +17,6 @@ path = "src/wc.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["pipes"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } bytecount = "0.6.2" utf-8 = "0.7.6" unicode-width = "0.1.8" @@ -29,6 +28,3 @@ libc = "0.2" [[bin]] name = "wc" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/wc/src/main.rs b/src/uu/wc/src/main.rs index b58b9cac7..a89861765 100644 --- a/src/uu/wc/src/main.rs +++ b/src/uu/wc/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_wc); +uucore::bin!(uu_wc); diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index edc539197..c7e53d0de 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -133,7 +133,7 @@ impl Input { } } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let usage = usage(); diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index 437705064..9559bdc3c 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -17,11 +17,7 @@ path = "src/who.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["utmpx"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [[bin]] name = "who" path = "src/main.rs" - -[package.metadata.cargo-udeps.ignore] -normal = ["uucore_procs"] diff --git a/src/uu/who/src/main.rs b/src/uu/who/src/main.rs index a093201a1..59edbba77 100644 --- a/src/uu/who/src/main.rs +++ b/src/uu/who/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_who); +uucore::bin!(uu_who); diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index 41387d21a..8df10b745 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -59,7 +59,7 @@ fn get_long_usage() -> String { ) } -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args .collect_str(InvalidEncodingHandling::Ignore) diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index 7c3436425..8098e8065 100644 --- a/src/uu/whoami/Cargo.toml +++ b/src/uu/whoami/Cargo.toml @@ -17,7 +17,6 @@ path = "src/whoami.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3", features = ["lmcons"] } diff --git a/src/uu/whoami/src/main.rs b/src/uu/whoami/src/main.rs index 40de26564..7e9d7276a 100644 --- a/src/uu/whoami/src/main.rs +++ b/src/uu/whoami/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_whoami); +uucore::bin!(uu_whoami); diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index e1640f204..f55e026da 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -19,7 +19,7 @@ mod platform; static ABOUT: &str = "Print the current username."; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { uu_app().get_matches_from(args); let username = platform::get_username().map_err_context(|| "failed to get username".into())?; diff --git a/src/uu/yes/Cargo.toml b/src/uu/yes/Cargo.toml index b8d121cdf..131b999db 100644 --- a/src/uu/yes/Cargo.toml +++ b/src/uu/yes/Cargo.toml @@ -17,7 +17,6 @@ path = "src/yes.rs" [dependencies] clap = { version = "3.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["pipes"] } -uucore_procs = { version=">=0.0.8", package="uucore_procs", path="../../uucore_procs" } [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] nix = "0.23.1" diff --git a/src/uu/yes/src/main.rs b/src/uu/yes/src/main.rs index dc5bf6a0c..8d119cf5c 100644 --- a/src/uu/yes/src/main.rs +++ b/src/uu/yes/src/main.rs @@ -1 +1 @@ -uucore_procs::main!(uu_yes); +uucore::bin!(uu_yes); diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index e6ae3abbf..22c9a5d12 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -23,7 +23,7 @@ mod splice; // systems, but honestly this is good enough const BUF_SIZE: usize = 16 * 1024; -#[uucore_procs::gen_uumain] +#[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().get_matches_from(args); diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 06f2c5fbc..3a6bf25c1 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -16,6 +16,7 @@ edition = "2018" path="src/lib/lib.rs" [dependencies] +uucore_procs = { version=">=0.0.12", path="../uucore_procs" } clap = "3.0" dns-lookup = { version="1.0.5", optional=true } dunce = "1.0.0" diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 7a5ca66cb..2bbf85dc1 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -16,6 +16,8 @@ mod macros; // crate macros (macro_rules-type; exported to `crate::...`) mod mods; // core cross-platform modules mod parser; // string parsing modules +pub use uucore_procs::*; + // * cross-platform modules pub use crate::mods::backup_control; pub use crate::mods::display; @@ -77,6 +79,19 @@ use once_cell::sync::Lazy; use crate::display::Quotable; +#[macro_export] +macro_rules! bin { + ($util:ident) => { + pub fn main() { + use std::io::Write; + uucore::panic::mute_sigpipe_panic(); // suppress extraneous error output for SIGPIPE failures/panics + let code = $util::uumain(uucore::args_os()); // execute utility code + std::io::stdout().flush().expect("could not flush stdout"); // (defensively) flush stdout for utility prior to exit; see + std::process::exit(code); + } + }; +} + pub fn get_utility_is_second_arg() -> bool { crate::macros::UTILITY_IS_SECOND_ARG.load(Ordering::SeqCst) } diff --git a/src/uucore/src/lib/mods/error.rs b/src/uucore/src/lib/mods/error.rs index 37231576f..24de6434b 100644 --- a/src/uucore/src/lib/mods/error.rs +++ b/src/uucore/src/lib/mods/error.rs @@ -139,7 +139,7 @@ pub type UResult = Result>; /// The main routine would look like this: /// /// ```ignore -/// #[uucore_procs::gen_uumain] +/// #[uucore::main] /// pub fn uumain(args: impl uucore::Args) -> UResult<()> { /// // Perform computations here ... /// return Err(LsError::InvalidLineWidth(String::from("test")).into()) diff --git a/src/uucore_procs/Cargo.toml b/src/uucore_procs/Cargo.toml index 040198063..800fc289f 100644 --- a/src/uucore_procs/Cargo.toml +++ b/src/uucore_procs/Cargo.toml @@ -18,9 +18,3 @@ proc-macro = true [dependencies] proc-macro2 = "1.0" quote = "1.0" -syn = { version="1.0", features = ["full"] } - -[features] -default = [] -# * non-default features -debug = ["syn/extra-traits"] ## add Debug traits to syn structures (for `println!("{:?}", ...)`) diff --git a/src/uucore_procs/src/lib.rs b/src/uucore_procs/src/lib.rs index 13b1dae3b..3a32dab83 100644 --- a/src/uucore_procs/src/lib.rs +++ b/src/uucore_procs/src/lib.rs @@ -2,100 +2,20 @@ extern crate proc_macro; use proc_macro::TokenStream; -use proc_macro2::{Ident, Span}; use quote::quote; -use syn::{self, parse_macro_input, ItemFn}; //## rust proc-macro background info //* ref: @@ //* ref: [path construction from LitStr](https://oschwald.github.io/maxminddb-rust/syn/struct.LitStr.html) @@ -//## proc_dbg macro -//* used to help debug the compile-time proc_macro code - -#[cfg(feature = "debug")] -macro_rules! proc_dbg { - ($x:expr) => { - dbg!($x) - }; -} -#[cfg(not(feature = "debug"))] -macro_rules! proc_dbg { - ($x:expr) => {}; -} - -//## main!() - -// main!( EXPR ) -// generates a `main()` function for utilities within the uutils group -// EXPR == syn::Expr::Lit::String | syn::Expr::Path::Ident ~ EXPR contains the lexical path to the utility `uumain()` function -//* NOTE: EXPR is ultimately expected to be a multi-segment lexical path (eg, `crate::func`); so, if a single segment path is provided, a trailing "::uumain" is automatically added -//* for more generic use (and future use of "eager" macros), EXPR may be in either STRING or IDENT form - -struct Tokens { - expr: syn::Expr, -} - -impl syn::parse::Parse for Tokens { - fn parse(input: syn::parse::ParseStream) -> syn::Result { - Ok(Tokens { - expr: input.parse()?, - }) - } -} - -#[proc_macro] -pub fn main(stream: TokenStream) -> TokenStream { - let Tokens { expr } = syn::parse_macro_input!(stream as Tokens); - proc_dbg!(&expr); - - const ARG_PANIC_TEXT: &str = - "expected ident lexical path (or a literal string version) to 'uumain()' as argument"; - - // match EXPR as a string literal or an ident path, o/w panic!() - let mut expr = match expr { - syn::Expr::Lit(expr_lit) => match expr_lit.lit { - syn::Lit::Str(ref lit_str) => lit_str.parse::().unwrap(), - _ => panic!("{}", ARG_PANIC_TEXT), - }, - syn::Expr::Path(expr_path) => expr_path, - _ => panic!("{}", ARG_PANIC_TEXT), - }; - proc_dbg!(&expr); - - // for a single segment ExprPath argument, add trailing '::uumain' segment - if expr.path.segments.len() < 2 { - expr = syn::parse_quote!( #expr::uumain ); - }; - proc_dbg!(&expr); - - let f = quote::quote! { #expr(uucore::args_os()) }; - proc_dbg!(&f); - - // generate a uutils utility `main()` function, tailored for the calling utility - let result = quote::quote! { - fn main() { - use std::io::Write; - uucore::panic::mute_sigpipe_panic(); // suppress extraneous error output for SIGPIPE failures/panics - let code = #f; // execute utility code - std::io::stdout().flush().expect("could not flush stdout"); // (defensively) flush stdout for utility prior to exit; see - std::process::exit(code); - } - }; - TokenStream::from(result) -} - #[proc_macro_attribute] -pub fn gen_uumain(_args: TokenStream, stream: TokenStream) -> TokenStream { - let mut ast = parse_macro_input!(stream as ItemFn); - - // Change the name of the function to "uumain_result" to prevent name-conflicts - ast.sig.ident = Ident::new("uumain_result", Span::call_site()); +pub fn main(_args: TokenStream, stream: TokenStream) -> TokenStream { + let stream = proc_macro2::TokenStream::from(stream); let new = quote!( pub fn uumain(args: impl uucore::Args) -> i32 { - #ast - let result = uumain_result(args); + #stream + let result = uumain(args); match result { Ok(()) => uucore::error::get_exit_code(), Err(e) => { diff --git a/tests/benches/factor/Cargo.toml b/tests/benches/factor/Cargo.toml index 5d9f39620..eb3d69105 100644 --- a/tests/benches/factor/Cargo.toml +++ b/tests/benches/factor/Cargo.toml @@ -16,7 +16,6 @@ criterion = "0.3" rand = "0.8" rand_chacha = "0.2.2" - [[bench]] name = "gcd" harness = false diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 07597cf15..92637dfbe 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -43,6 +43,8 @@ static TEST_MOUNT_COPY_FROM_FOLDER: &str = "dir_with_mount"; static TEST_MOUNT_MOUNTPOINT: &str = "mount"; #[cfg(any(target_os = "linux", target_os = "freebsd"))] static TEST_MOUNT_OTHER_FILESYSTEM_FILE: &str = "mount/DO_NOT_copy_me.txt"; +#[cfg(unix)] +static TEST_NONEXISTENT_FILE: &str = "nonexistent_file.txt"; #[test] fn test_cp_cp() { @@ -1429,3 +1431,16 @@ fn test_copy_through_dangling_symlink() { .fails() .stderr_only("cp: not writing through dangling symlink 'target'"); } + +#[test] +#[cfg(unix)] +fn test_cp_archive_on_nonexistent_file() { + new_ucmd!() + .arg("-a") + .arg(TEST_NONEXISTENT_FILE) + .arg(TEST_EXISTING_FILE) + .fails() + .stderr_only( + "cp: cannot stat 'nonexistent_file.txt': No such file or directory (os error 2)", + ); +} diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index a68b31432..559fe3f47 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -7,6 +7,11 @@ use crate::common::util::*; extern crate regex; use self::regex::Regex; +#[cfg(unix)] +use nix::unistd::{close, dup2}; +#[cfg(unix)] +use std::os::unix::io::AsRawFd; + use std::collections::HashMap; use std::path::Path; use std::thread::sleep; @@ -150,10 +155,7 @@ fn test_ls_io_errors() { at.symlink_file("does_not_exist", "some-dir2/dangle"); at.mkdir("some-dir3"); at.mkdir("some-dir3/some-dir4"); - at.mkdir("some-dir3/some-dir5"); - at.mkdir("some-dir3/some-dir6"); - at.mkdir("some-dir3/some-dir7"); - at.mkdir("some-dir3/some-dir8"); + at.mkdir("some-dir4"); scene.ccmd("chmod").arg("000").arg("some-dir1").succeeds(); @@ -190,7 +192,7 @@ fn test_ls_io_errors() { .stderr_contains("Permission denied") .stdout_contains("some-dir4"); - // test we don't double print on dangling link metadata errors + // don't double print on dangling link metadata errors scene .ucmd() .arg("-iRL") @@ -199,6 +201,62 @@ fn test_ls_io_errors() { .stderr_does_not_contain( "ls: cannot access 'some-dir2/dangle': No such file or directory\nls: cannot access 'some-dir2/dangle': No such file or directory" ); + + #[cfg(unix)] + { + at.touch("some-dir4/bad-fd.txt"); + let fd1 = at.open("some-dir4/bad-fd.txt").as_raw_fd(); + let fd2 = 25000; + let rv1 = dup2(fd1, fd2); + let rv2 = close(fd1); + + // dup and close work on the mac, but doesn't work in some linux containers + // so check to see that return values are non-error before proceeding + if rv1.is_ok() && rv2.is_ok() { + // on the mac and in certain Linux containers bad fds are typed as dirs, + // however sometimes bad fds are typed as links and directory entry on links won't fail + if PathBuf::from(format!("/dev/fd/{fd}", fd = fd2)).is_dir() { + scene + .ucmd() + .arg("-alR") + .arg(format!("/dev/fd/{fd}", fd = fd2)) + .fails() + .stderr_contains(format!( + "cannot open directory '/dev/fd/{fd}': Bad file descriptor", + fd = fd2 + )) + .stdout_does_not_contain(format!("{fd}:\n", fd = fd2)); + + scene + .ucmd() + .arg("-RiL") + .arg(format!("/dev/fd/{fd}", fd = fd2)) + .fails() + .stderr_contains(format!("cannot open directory '/dev/fd/{fd}': Bad file descriptor", fd = fd2)) + // don't double print bad fd errors + .stderr_does_not_contain(format!("ls: cannot open directory '/dev/fd/{fd}': Bad file descriptor\nls: cannot open directory '/dev/fd/{fd}': Bad file descriptor", fd = fd2)); + } else { + scene + .ucmd() + .arg("-alR") + .arg(format!("/dev/fd/{fd}", fd = fd2)) + .succeeds(); + + scene + .ucmd() + .arg("-RiL") + .arg(format!("/dev/fd/{fd}", fd = fd2)) + .succeeds(); + } + + scene + .ucmd() + .arg("-alL") + .arg(format!("/dev/fd/{fd}", fd = fd2)) + .succeeds(); + } + let _ = close(fd2); + } } #[test] diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index d55e13644..2005c0235 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -2,7 +2,7 @@ // * // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes asciilowercase +// spell-checker:ignore xzaaa sixhundredfiftyonebytes ninetyonebytes asciilowercase fghij klmno pqrst uvwxyz extern crate rand; extern crate regex; @@ -12,11 +12,10 @@ use crate::common::util::*; use rand::SeedableRng; #[cfg(not(windows))] use std::env; -use std::io::Write; use std::path::Path; use std::{ fs::{read_dir, File}, - io::{BufWriter, Read}, + io::{BufWriter, Read, Write}, }; fn random_chars(n: usize) -> String { @@ -425,3 +424,19 @@ creating file 'xaf' ", ); } + +#[test] +fn test_number() { + let (at, mut ucmd) = at_and_ucmd!(); + let file_read = |f| { + let mut s = String::new(); + at.open(f).read_to_string(&mut s).unwrap(); + s + }; + ucmd.args(&["-n", "5", "asciilowercase.txt"]).succeeds(); + assert_eq!(file_read("xaa"), "abcde"); + assert_eq!(file_read("xab"), "fghij"); + assert_eq!(file_read("xac"), "klmno"); + assert_eq!(file_read("xad"), "pqrst"); + assert_eq!(file_read("xae"), "uvwxyz"); +} diff --git a/tests/by-util/test_tail.rs b/tests/by-util/test_tail.rs index 40a229d3a..edb8066d6 100644 --- a/tests/by-util/test_tail.rs +++ b/tests/by-util/test_tail.rs @@ -548,3 +548,17 @@ fn test_no_such_file() { fn test_no_trailing_newline() { new_ucmd!().pipe_in("x").succeeds().stdout_only("x"); } + +#[test] +fn test_lines_zero_terminated() { + new_ucmd!() + .args(&["-z", "-n", "2"]) + .pipe_in("a\0b\0c\0d\0e\0") + .succeeds() + .stdout_only("d\0e\0"); + new_ucmd!() + .args(&["-z", "-n", "+2"]) + .pipe_in("a\0b\0c\0d\0e\0") + .succeeds() + .stdout_only("b\0c\0d\0e\0"); +} diff --git a/tests/fixtures/split/asciilowercase.txt b/tests/fixtures/split/asciilowercase.txt index b0883f382..e85d5b452 100644 --- a/tests/fixtures/split/asciilowercase.txt +++ b/tests/fixtures/split/asciilowercase.txt @@ -1 +1 @@ -abcdefghijklmnopqrstuvwxyz +abcdefghijklmnopqrstuvwxyz \ No newline at end of file